Module 6 - Geometries

This is the hardest module as we had to go through nested loops which I definitely hate (to be honest haha). I had an issue at first on writing a file as I can't seem to find where the file was created. After that the nested loop got me banging my head at my laptop though again through the help of the comments template that was already filled in, I was able to extract my codes line per line. The trick here is to make it short and sweet when defining your codes and if you can concatenate them in one print or write statement then do that. It makes your code neat as well as it will be less confusing if you hit an error.

Below is the screenshot of the results after I have ran the code. In addition, I also added a print statement in my code to show the same results as the text file and then another print statement at the end of the code. This helped me to not waste time cross-checking files and I can just check if it has ran successfully using the IPython terminal.



Take it one step at a time, instead of coding immediately you can enumerate it in a piece of paper the steps you need to take. I suggest creating a flowchart + comments section immediately in your code before you start coding. This will help you to extract the code piece by piece and will lessen confusion as you code - especially if you are to code hundreds of lines already. In addition, adding print statement in each part will let you know where it is going wrong.




Additional notes to ponder:
  • Note the differences between features/rows, arrays, points/vertices. Features/rows refer to an entity or row of your table/dataset that has a set of properties. Arrays are that contain point/line/polygon objects or a list that can also be used to construct geometry objects. While, points/vertices are geometries/shapes of features in your shapefile/feature class.
  • Check your nested loops by adding print output if necessary. This will help you to see where you are at.
  • Use the codes f.open, f.write, f.close to create text files in ArcGIS Python. You can also do the other way around by creating a shapefile/feature class (CreateFeatureclass_management) from a data in a text file.
  • You can use the InsertCursor or Insert Row to insert and update cursors creating new features and updating existing features.




Comments

Popular posts from this blog

M1 S4 - Suitability Analysis / Least Cost Path

GIS Portfolio

Module 4 - Geoprocessing