Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have an offline database which has lat & long coordinates. The functionality I need to provide is to have a (latitude, longitude) point which will have country and city in it. Once the user has selected the location, user shall be able to download the shape file to the user defined location.

I am able to design the GUI but don't know how should I do the download. It would be real great if you guys can explain with examples as I am new to python. Or may be simple code. I have to run this on ArcGIS 10.

The flow is like this:

  • Select the country ,
  • then select the city,
  • create shapefile,
  • then a button which can let the user download the shape file.

I did try to implement http://code.activestate.com/recipes/496685-downloading-a-file-from-the-web/ but could not get through.

Thanks

share|improve this question
    
Can you elaborate more on what you mean by "Once the user has selected the location"? Do you mean a manual selection in the view of ArcMap or a combobox drop down value? –  artwork21 Oct 31 '11 at 11:24
    
Once the user has selected on the combobox. –  Mehul Oct 31 '11 at 11:41
    
The flow is like this - Select the country , then seclect the city, create shape file , then a button which can let the user download the shape file. –  Mehul Oct 31 '11 at 11:43
    
I did try to implement code.activestate.com/recipes/… but could not get through –  Mehul Oct 31 '11 at 11:44
2  
Are you trying to download (save) the SHP file locally from ArcMap Desktop, or trying to save the data from a web app? Are you wanting to simply create a SHP file? –  RyanDalton Oct 31 '11 at 14:28
show 1 more comment

1 Answer 1

I would say that this is more of a Python specific question than a GIS question since it sounds like what you are looking to know is how to take a user's choice, download a file based on it, and save it to a location.

The answer to this question definitely depends on where you are running into your problem, but the basic steps you need to take are:

  1. Write the classes in your ArcToolbox that populate your dropdowns with valid choices.
  2. Write the script that retrieves the choice from arcgis via arcpy.getParameterAsText() (docs) - the ESRI documentation on this is excellent
  3. Download the file - to either a temporary location or the user specified location (you can once again use getParameterAsText(), validate that the path exists, and pass it to your downloading functions)
  4. If you would like to return the shape into ArcMap 10, you can then use something like features = arcpy.MakeFeatureLayer_management(shapefile_location) (docs) to load the shapefile into memory, then use arcpy.setParameter(parameter_number,features) (docs) - where the numbered parameter is set to output in your script tool's definition. That will then return your shapefile into the ArcMap table of contents as a layer.

I'm not sure if you were looking to return the layer into the ArcMap ToC, but that's how you would do it. If you are having trouble with downloading a file in Python though, someone may be able to help you here, but also check the python section on StackOverflow.

I'll also add that I'm happy to elaborate on any of these steps and what to do, but without being totally clear on what's needed I'll save that for now. The actual file download is the part I haven't done in Python and which may be better suited for StackOverflow.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.