Select to view content in your preferred language

FAO Robert Scheitlin or anyone who knows about saved graphics as text files

4236
10
06-28-2011 01:54 AM
grahamcooke
Regular Contributor
This functionality is in Roberts enhanced draw widget and works great.

What I would like to know is ifanyone knows of any way to import these text files into ArcMap to create geo-referenced shape files that can then be saved away to ArcSDE as feature classes.

any help / advice / hints would be appreciated

thanks

Graham
Tags (2)
0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Emeritus
Graham,

   I did look into this... But as I am not motivated to get back into my .net development days and time is at a premium for me normally, I did not do anything with it. Based on what I know this is doable if some .net wizard wants to convert the JSON and parse the text and use ArcObjects to create features.
0 Kudos
AlexJones
Emerging Contributor
This is the Python script that I used to convert from the saved text/json to a shapefile. I never polished it up due to a lack of time. It should work as long as you change the path to the file name, the workspace and possibly the coordinate system. It would be very easy to convert from shp to sde if this portion works for you. Its not in .net so it may not be what you are looking for.
0 Kudos
grahamcooke
Regular Contributor
Robert,

Thanks for replying. Another question for you... did you find a way around the adobe "feature" of removing the .txt extension when the user renames the save file? getting users to retype the extension is a bit of an impossible mission and is causing me to get untold support calls about "lost files". because when they come to reload it only looks for .txt but they saved the file without an extension

TheJones23:

Thanks for sharing. I havent ever used python before so please assume i am a complete idiot....any chance you can explain how I go about using this script? Do I need to execute it within ArcMap somehow (as a GP tool?) or can i somehow call it from within flex?

cheers,

Graham
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Graham,

   I have searched high and low and there is now way around that issue as it is there for security reasons that have not and probably will not change.
0 Kudos
AlexJones
Emerging Contributor
Graham,
This script would need to be run directly from a python ide. Idle, Aptana/PyDev, PyCharm, etc. If you just open the .py file in the ide you will see at the top a path to each piece you need to change. Change them and then hit run from the ide. If it works you will have shapefiles in the output directory. Currently C:\TEMP is the directory you will see them in. If you need more help just email me. alexander.t.jones at gmail.com

Alex
grahamcooke
Regular Contributor
I am bumping this as unfortunately Alex can no longer be of assistance as the polygons i need to convert are quite complicated.

Are there any other python experts out there who have come up with a way of converting JSON in text format to a shape file?
0 Kudos
MattiasEkström
Frequent Contributor
I recently tried Alex Jones python script to convert saved graphics from enhaced Draw Widget to shapefiles. I ran into problems when the script is inserting attribute values, I think it was because the fields are all text fields, but some values are not text strings, so I just made sure they are by using str(). Then it works for me.
I also made a tool/script for ArcGIS toolbox, where the user can browse for txt-file, output location and coordinate system and run it in ArcGIS instead of running it from a python ide and using hard coded paths. It makes it a bit easier to use, if anyone is interessted here's the toolbox and script.
Just unzip it somewhere and then rightclick in your toolbox and choose add tollbox and point to the tbx file you just unzipped.
Thanks to Alex for sharing the script!
grahamcooke
Regular Contributor
Thankyou Mattias! I will have a play with this and let you know how I get on
0 Kudos
JORGELAGOS2
Emerging Contributor
This is the Python script that I used to convert from the saved text/json to a shapefile. I never polished it up due to a lack of time. It should work as long as you change the path to the file name, the workspace and possibly the coordinate system. It would be very easy to convert from shp to sde if this portion works for you. Its not in .net so it may not be what you are looking for.




I am trying to use the JsonToShp.py script but I am getting the following error:



Traceback (most recent call last):
  File "C:\deleteme\JsonToShp.py", line 202, in <module> main()
  File "C:\deleteme\JsonToShp.py", line 52, in main
    createPoints(pntFc, ptFeats)
  File "C:\deleteme\JsonToShp.py", line 142, in createPoints
    feat.setValue(field[0:9], f[field])
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\arcobjects\arcobjects.py", line 1007, in setValue
    return convertArcObjectToPythonObject(self._arc_object.SetValue(*gp_fixargs(args)))
ValueError: Row: Invalid input value for SetValue


Any idea?

Thanks

Jorge
0 Kudos