project-open-data / esri2open

this repo is an ESRI toolbox and tool(s) that export ESRI Feature Classes to open data formats, CSV, JSON, and GeoJSON
MIT License
257 stars 63 forks source link

CSV/JSON library #2

Closed calvinmetcalf closed 11 years ago

calvinmetcalf commented 11 years ago

Would it be easier to use python's built in CSV and JSON libraries?

I made a similar library and managed to save a lot of logic by doing that.

This is half an issue and half me trying to figure out if paranoid I missed some downside of using the json library.

feomike commented 11 years ago

likely would have been easier w/ those libraries, but i am not that bright to have recognized it. your code is clean, looks good. my project was a bit of playing around, but looking at yours makes me think there is some more to gain. thanks for sharing.

calvinmetcalf commented 11 years ago

Haha no problem I created mine for pretty much the same reason, the csv.DictReader class would probably allow you to share almost all of the code between JSON and csv.

feomike commented 11 years ago

sweet; i'll look at it more. did you have any problems w/ inside rings or anything like that?

calvinmetcalf commented 11 years ago

I wrote that a while ago, I did have problems with inside rings when I was converting from esriJSON to geoJSON, I don't think I bothered dealing with them in the python tool, I also apparently didn't believe in for-loops.

feomike commented 11 years ago

lol; your style is beautiful; terse. again, nice job. i'll take some things from it.

calvinmetcalf commented 11 years ago

I think I was writing a lot of CoffeeScript at the time.

calvinmetcalf commented 11 years ago

I double checked your script against a large data set with multi-polygons and donuts it somewhat it ended up just not giving geometries back, which is better then mine which just erred on on the date object and then after fixing that it turned out no I didn't deal with donuts.

calvinmetcalf commented 11 years ago

btw I managed to get donut holes working in the most recent version.

feomike commented 11 years ago

oh, sweet! i was trying to tick these off one at a time, and juggling other things. i was going to look at this issue tomorrow. but it it is all good, then cool. will this be useful for you?

calvinmetcalf commented 11 years ago

I was just closing this because it wasn't really an issue as much as a discussion thread, I managed to get holes to work here, basically you need to split the polygon at the missing point and start a new array, to avoid the conection between the outside and inside. donut Also I learned the hard way you need to check the length of the polygon that esri gives you as ESRI allows polygons that only have one point (length of 2 because the first and last point are repeated) but GeoJSON requires minimum of 3 distinct points (length of 4)

feomike commented 11 years ago

right; i had thought of requiring an esri repair geometry as part of the script, but the drawback there is that changes data. i figure it is better to have a workflow whereby the user actually controls what they want to do. i guess an enhancement would be to have a) check geometry run first, and if any errors occur, bail and let the use fix them and b) if geometry is null, skip entire row or something like that.

btw, nice use of stamen tiles.

calvinmetcalf commented 11 years ago

I Was thinking one point polygons would just be turned into points and if part of a multipolygon a geometry collection

calvinmetcalf commented 11 years ago

maybe this will be more clear: esri flowchart

feomike commented 11 years ago

that looks right, and is killing me. very funny/appropriate

calvinmetcalf commented 11 years ago

the real joke is that that isn't complete as I bet ESRI handles polylines with only 1 point

calvinmetcalf commented 11 years ago

also sadly that wasn't made as a joke as much as an illfated attempt to track the progress of my tool. calvinmetcalf/esri2geo#10

Speaking of which, would you be interested in merging esri2open and esri2geo it looks like we pretty much have the exact same goals.