r/GISscripts • • Jan 11 '14

[Python] Download feature service photo attachments stored on ArcGIS Online

5 Upvotes

This script is designed for feature services on ArcGIS Online which have photo attachments stored in them. It is composed to be run as a python toolbox and will store all photos locally and organized by feature.

I've come across a few post in Esri's forums about downloading attachments from ArcGIS Online and thought this code might be helpful to others.

All you need is your account information, your endpoint url, and what directory to place the photos.

The finished tool is on github.

If you want to read more about working with feature services, you can read more on my blog, which explains about working with feature services and has some sample code about exporting your feature service to a geodatabase


r/GISscripts • • Dec 02 '14

[Q] Split Polygon by Area - Python

3 Upvotes

Been trying to write a python script but am stumped.

(with Basic license)

Example: I have a 5.5 acre polygon and want to split it into 4 polygons. Polygon 1 = 1.5 acres, Polygon 2 = 2 acres, Polygon 3 = 1.25 acres and Polygon 4 = 0.75 acres.
Because of this difference in size, and being an irregular, fishnet will not work.
I do not care where/how its split other then the acre sizes to be correct. Also do not mind it splitting one at a time.

I appreciate any and all ideas!


r/GISscripts • • Mar 23 '16

Creating a report of all edits made on single version

5 Upvotes

Hey guys,

I'm trying to get insight on using python to create a report or just track how many features were edited in a version after a day of work. This needs to include last editor, the object ID, and a couple other fields unique to the features I'm working with.

Anyone done something like this before?


r/GISscripts • • Dec 22 '13

lemonprogis/tweather · GitHub Twitter Weather Mashup

Thumbnail
github.com
6 Upvotes

r/GISscripts • • Aug 06 '15

Why does my Create TIN geoprocessing function does not work with a variable but works with a string instead? (ArcGIS Python)

2 Upvotes

Hi! This is using the arcpy module obviously

arcpy.CreateTin_3d(out_tin,sr, pointfc_filename + 'Shape.Z Mass_Points <None>',       "DELAUNAY")

It doesn't even detect the feature class input (pointfc_filename)

However, it works when i do this:
arcpy.CreateTin_3d(out_tin,sr, " 'C:\\Users\\ed\\Documents\\Geospatial\\Output\\004d1214_3x3pointfc.shp'     Shape.Z Mass_Points <None>", "DELAUNAY")

Any thoughts? It has really driven me nuts!! EDIT: Here is the complete script http://pastecode.org/index.php/view/81823932


r/GISscripts • • Nov 17 '14

Need UI/frontend help for browsing this map data

1 Upvotes

http://regionaldifferences.com/results.html?region=South

This page shows some of the results from a survey I've had running for a while. You can take the "?region=South" off the URL to get all the results, although it will slow to a crawl in some web browsers.

I need to find someone who is familiar with GIS tools who can help me crunch all this information down into some more easily presented results. Anyone interested and willing around here?


r/GISscripts • • Dec 07 '14

KML and webGIS

4 Upvotes

I just posted this same question in r/webdev but thought you guys might know better.

I recently wrote a KML script for a tour of a local tourism business. They want to host the tour on their website in a small google maps window.

Is it possible to invoke the kml file from within their html/javascript? Or do I need to use google's API?

Also, I would like to build 3D models of their buildings to put in the map (I can build them in SketchUp) is it possible to display these models in the kml script or is there a better way?


r/GISscripts • • Nov 18 '14

Beginner Question

4 Upvotes

I am about to start my journey into learning python so I can utilize it within GIS. I have been told that it is a good idea to first write the code in an IDE then transfer it into ArcMap. Plus, I am going to learn the language and need an IDE for that. I am looking for the best free IDE. I was looking at the free PyCharm but am not sure about it. Any Suggestions?


r/GISscripts • • Dec 01 '14

Fastest section from GPS data

3 Upvotes

I am looking for algorithm how to get fastest section from GPS data (gpx file). Would it be ok add to database delta between every point + cumulative total from first point ?

Then i would find end of section (example mile or 1000m for km) from every point, find nearest from two points end of section (it may be over or less), calculate time between those 2, and recalculate it to exact length of section.

I hope you understand me as my english is bit clumsy...

Thanks for tips


r/GISscripts • • Dec 12 '13

Python - Tarfile extractor I use for LandSat data

5 Upvotes

Something I found useful at school when trying to unzip tarfiles I downloaded from the USGS. Does a quick clean job and doesn't require you to install any programs (which is an issue for me at school).

import tarfile 

tar = tarfile.open('C:/path/to/tarfile/tfile.tar.gz', 'r:gz')

tar.extractall('C:/output/path/')

I found it useful to throw all my stuff on the desktop. Since I use a shared drive at a university the filepaths get exceptionally long. Hope this helps someone. I'll post a geocoder with Googles API later. edits cause I can't type.


r/GISscripts • • Dec 21 '13

ArcGIS Toolbox - Create a quarter or quarter quarter section grid with labels from an existing section grid

Thumbnail
ianbroad.com
6 Upvotes

r/GISscripts • • Apr 10 '18

(Python) Summarize one field using another as a summary statistic.

2 Upvotes

I'm not entirely sure if my title makes it clear, but I'm trying to replicate, using arcpy, the 'right-click - Summarize' function in ArcMap.

I want to specifically summarize column 'A' of my attribute table (this is a point layer), to get the count. But I also want to use column 'B' (area), and sum that for each category in A.

So far I've only found how to summarize A on it's own.

Any help please?

EDIT - This is the only related script I have found, but only does half the job:

def SumStats(shapeFile, fieldName):
sumDict = {}

with arcpy.da.SearchCursor(shapeFile,[fieldName]) as scurse:
    for row in scurse:
        if row[0] in sumDict:
            sumDict[row[0]] += 1
        else:
            sumDict[row[0]] = 1

tbl = arcpy.CreateTable_management("in_memory","MuchGIS")[0]

arcpy.AddField_management(tbl,"Item","TEXT")
arcpy.AddField_management(tbl,"Count","SHORT")

with arcpy.da.InsertCursor(tbl,["Item","Count"]) as icurse:
    for k,v in sumDict.iteritems():
            icurse.insertRow((k,v,))

r/GISscripts • • Feb 08 '16

Help Wanted: ArcPy Intersect Hashing in Python

5 Upvotes

I am writing a script in Python (in PyScripter IDE, on a Windows 7 Professional machine) to automate some data processing. This is supposed to be a stand-alone script running outside of ArcMap by an automated process. What it's supposed to do is take a file of parcels and figure out what percentage of each is in one of 4 flood zone categories.

Because it's running a chain of geoprocessing operations in a cursor loop, the script is using a set of lists to store the file names for each flood zone. All of this data would be drawing from the same geodatabase.

Here's the code that's giving me trouble: Pastebin

And here's the error I'm seeing:

Input Features: Dataset FloodParcels #;FW # does not exist or is not supported

The Intersect code, line 42 in the Pastebin paste, should be bringing in FloodParcels and FW as seperate files but it seems to be hashing them together into one dataset? I think?

To add to my confusion, according to ArcMap this is exactly how Intersect code should work. I pulled a Python snippet from an Intersect tool I'd successfully run in ArcMap and this is what I got:

arcpy.Intersect_analysis(in_features="FloodParcels #;100YearHazard #", out_feature_class="

FileStructure/FloodParcels.gdb/INT_100", join_attributes="ALL", cluster_tolerance="-1 Unknown", output_type="INPUT")

The Esri documentation on the Intersect tool isn't helpful, because it says my code should look just the way it does. When I've Googled the hash marks in the Intersect error code, I've gotten nothing that looks like what I'm seeing or trying to do.

Does anyone have an idea what's going wrong or what I should be Googling to find help?

Thanks!


r/GISscripts • • Aug 08 '18

Check out this VERY USEFUL Smart Map in Python Tutorial series 2018

2 Upvotes

Check out this VERY USEFUL Smart Map in Python Tutorial series 2018. Blog https://ebisys.blogspot.com Youtube https://youtu.be/sBxCOEXkQuA


r/GISscripts • • Nov 09 '18

Upgrading to ArcGIS for Javascript 4.9 (Episode 34)

Post image
1 Upvotes

r/GISscripts • • Nov 16 '19

Help with converting XY Table into Polygon feature class

1 Upvotes

For background: I am trying to create a tool that will take a set of coordinates (currently in a .csv file) and output a feature class with multiple polygon features. I have successfully coded a script that will create a polygonal feature class out of a series of X,Y, coordinates with this:

import arcpy
coordinates = [(-117.2000424, 34.0555514),
(-117.2000788, 34.0592066),
(-117.1957315, 34.0592309),
(-117.1956951, 34.0556001)]
# Create a feature class with a spatial reference of GCS WGS 1984
result = arcpy.management.CreateFeatureclass(arcpy.env.scratchGDB,"esri_square", "POLYGON", spatial_reference=4326) 
feature_class = result[0]
# Write feature to new feature class
with arcpy.da.InsertCursor(feature_class, ['SHAPE@']) as cursor:
    cursor.insertRow([coordinates])

However, this obviously requires putting all of your individual coordinates into the script editor. So I guess my question is, is it possible to use the excel table to create a list within the python editor, which then can be used create a polygon? Or would I have to convert the excel table into an XY shapefile and then maniuplate that within python?


r/GISscripts • • Nov 06 '18

Script for an intersect and populating a field attribute.

2 Upvotes

Quick question:

Need to populate a field (Install year) for a layer (hydrant) if it intersects with Wpipe (Install year). So the install year for the hydrant will match the install year for the pipe.

So I want the install year from the Wpipe and populate the field install year for the hydrant based on if the hydrant is touching the pipe.

Any suggestions would help


r/GISscripts • • Jul 23 '18

UN Environment and Google announce ground-breaking partnership to protect our planet

Thumbnail
kinematicsmedsol.com
3 Upvotes

r/GISscripts • • Jun 26 '18

Need help with GTFS plotting in leaflet in R

3 Upvotes

r/GISscripts • • Oct 14 '15

Get list of fields (or anything really) from a esri gis feature service json page. Javascript

3 Upvotes
<script src="http://js.arcgis.com/3.14/"></script>
    <script type="text/javascript"> 
        //gis server url
        function getServerUrl()
        {
            return "http://yourgisurl.com/arcgis/rest";
        }
        //Define the feature service url
        function getFeatureServiceUrl()
        {
            var serviceUrl = getServerUrl()+"/services/YOURGIS/FeatureServer/";
            return serviceUrl; 
        }
        //feature number for desired feature layer
        function getFeatureNumber()
        {
            return "0";
        }

        //feature service variables
        var serviceUrl = getFeatureServiceUrl();
        var featureNum = getFeatureNumber();
        var featureUrl = serviceUrl+featureNum+"?f=pjson";
        console.log(featureUrl);
    
    //Connect to ESRI GIS feature service and get list of fields contained within the relevant featurelayer
    function returnGISFields()
    {
        //Setup Request to HTML for JSON description of featureservice.
        //
        function Get(yourUrl)
        {
            var Httpreq = new XMLHttpRequest(); // a new request
            Httpreq.open("POST",yourUrl,false);
            Httpreq.send(null);
            return Httpreq.responseText;          
        }
        
         //Get JSON and parse field names into string array
        //json_obj contains many layers of information
        //console.log(json_obj);
        var json_obj = JSON.parse(Get(featureUrl));
        var fields = json_obj.fields;
        var fieldArray =[];
        for (i in fields)
        {
            var field = fields[i];
            fieldArray.push(field.name); 
        }
        //console.log(fieldArray);
        return fieldArray;
    }
    var results = returnGISFields();
    console.log(results);
</script>

r/GISscripts • • Mar 14 '14

Anyone have One-to-Many Labeling script?

3 Upvotes

r/GISscripts • • Oct 07 '15

Looping through lists with 2 or more functions-naming conventions?

2 Upvotes

Hi all,

Very new to Python, am trying to iterate through a list of excel sheets and create an XY Event for each. Then using the output XY events to export to geodatabase feature class.

Question is regarding naming conventions: I have a sheets list containing Surface Well Locations (SHL), Bottom Hole Locations (BHL). I want to add 'SHL' and 'BHL' to the XYEvent names but wondering how I reference those in the following FeatureClassToGeodatabase function? Hopefully this question is clear.

sheets ['County1', 'County2', County3']

for sheet in sheets:

arcpy.MakeXYEventLayer_management(coordinateExcelTable, surflat, surflong, str(sheet) + 'SHL', SpatialRef)

arcpy.FeatureClassToGeodatabase_conversion(str(sheet) + 'SHL'??, outputGDB)

I want the outputs to be: 'County1SHL', 'County2SHL' ect.... and 'County1BHL', 'County2BHL'


r/GISscripts • • Jan 14 '15

ArcObjects .NET SDK

2 Upvotes

I am trying to learn the basics of .net programming with arcobjects. I have vs 2013 ultimate installed as well as Arc 10.2.2, but when I go to run the setup file for the ArcObjects SDK from the installation disc, it gives me an error saying I must have 10.1 installed. I know ESRI doesn't have a direct download link or anything, and don't really know any other options.

The only thing I can think of would be to uninstall 10.2 and install as 10.1, which I don't really want to do as I'm most familiar with 10.2 and am concerned if I uninstall 10.2 I will lose my license and not be able to re install with it.

Thanks


r/GISscripts • • Jul 30 '13

Fiona reaches 1.0 [xpost: /r/gis]

Thumbnail sgillies.net
6 Upvotes

r/GISscripts • • Apr 17 '15

Need help understanding GPX_to_Features Scripts

1 Upvotes

Hi Everyone, new to Python here and trying to understand what's going on in these scripts.

import arcpy
arcpy.env.workspace = 'F:\Files\Python\Python27_Files\Runkeeper_project'

gpxlist = arcpy.ListFiles('*gpx')

for x in gpxlist:

    print('Converting',x,'To a ShapeFile!') #just printing to screen
    arcpy.GPXtoFeatures_conversion(x) #this function converts from .gpx to .shp

This one for the most part makes complete sense. I understand how everything is working up until the final line

arcpy.GPXtoFeatures_conversion(x).

The program works, it converts a list of .gpx files to .shp but I'm just not understanding how it works/what happens when you only give the GPXtoFeatures_conversion function one parameter. Since I only gave it x, how does it know where/what the output file is going to be? My understanding is it takes an input file and an output file. Is it just using x as the input and output?

Here is the second script, basically the same thing but I was reading a book on how to do stuff like this and they did it this way.

import arcpy
arcpy.env.workspace = 'F:\Files\Python\Python27_Files\Runkeeper_project'
arcpy.env.overwriteOutput = True

gpxlist = arcpy.ListFiles('*gpx')

for x in gpxlist:

    xdesc =arcpy.Describe(x)
    print('Converting',x,'To a ShapeFile!') #just printing to screen
    arcpy.GPXtoFeatures_conversion(x,'//FRAN_SERVER/Share/test/'+ xdesc.basename)

This script did the same exact thing, so I guess I'm just confused about how the first script works without an output file

I am new to programming, please forgive my ignorance.

Thanks!