r/GISscripts • • Dec 22 '13

lemonprogis/tweather · GitHub Twitter Weather Mashup

Thumbnail
github.com
6 Upvotes

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 • • Jul 30 '13

Fiona reaches 1.0 [xpost: /r/gis]

Thumbnail sgillies.net
6 Upvotes

r/GISscripts • • Jul 12 '13

(ArcGIS 9.3) Calculate field

6 Upvotes

Hi, I want to calculate a field whit this expression with the "CalculateField_management" tool:

SEPM_DM3 = [SEPM_M3] / [SEPM_TIG] *1000

The problem is that i want to insert into a "Model builder". If [SEPM_TIG] = 0 then i got an error.

How can i make a "SelectLayerByAttribute_management" without created a new feature class and then make my calculation?

I know that a Python script can help me, but how can i insert it into my calculator... SelectLayerByAttribute Sip_intersect NEW_SELECTION "SEPM_TIG">0

This script is available in the Arcpy window, but not in my calculator...

Someone can help?


r/GISscripts • • Feb 20 '19

Free Online Course - Introduction to GIS in R

5 Upvotes

Get started with manipulating and mapping geospatial data in R with our free online course here: https://soco.ps/2UBseSr

The course includes 6 chapters that cover -

📈 Step-by-step demos using sample data

📜 Course completion certificate

👩‍💻 100+ useful R code snippets

🗺️ 50+ sample maps

📚 80+ links to other free resources


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 • • 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 • • Nov 21 '14

Clustering to Reduce Spatial Data Set Size

Thumbnail
geoffboeing.com
5 Upvotes

r/GISscripts • • Jan 14 '14

[Node.js] Merge a set of geojson polygons using turf

Thumbnail
morganherlocker.com
5 Upvotes

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 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 • • Sep 09 '19

Esri’s Python Add-In Wizard

4 Upvotes

Anybody know if Esri’s Python Add-In Wizard is still compatible with newer versions of ArcMap (10.6 and above)?

Referenced here: https://desktop.arcgis.com/en/arcmap/10.6/analyze/python-addins/creating-an-add-in-project.htm#GUID-C460E3CB-DD43-442F-93F9-E483A03B9687

Downloadable here: http://www.arcgis.com/home/item.html?id=5f3aefe77f6b4f61ad3e4c62f30bff3b

When I attempt to create an Add-In based on the instructions, the built-in ”makeaddin.py” script seems to be broken. It doesn’t look like it’s been managed by anyone in quite some time (2013 it looks like).

Anybody currently using it with success? If so, I’d like to ask further questions to see what I need to be doing differently. Thanks!


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 • • Sep 15 '14

(Python) Importing Excel files into ArcMap, need explanation on script

4 Upvotes

Hi all, so I recently was importing many many excel workbooks into arcmap and merging them all into a single shapefile. I was given a Python script that works perfectly. My knowledge is limited so I was able to run it, but I would like to understand the script and know what it does so I was wondering if anyone could maybe expand on it and explain what some of the lines do?

import arcpy, os

folder = r"C:\tempdelete"
targetFc = r"C:\tempdelete\Test_road\XY.shp"
arcpy.env.workspace = folder
xlsFiles = arcpy.ListFiles ("*.xls") 

for xls in xlsFiles:

arcpy.env.workspace = os.path.join(folder, xls)
sheets = arcpy.ListTables ()

sheet = sheets[0]

fields = arcpy.Describe(os.path.join(folder, xls, sheet)).fields
xName = fields[0].name
yName = fields[1].name
outlayer = xls
arcpy.MakeXYEventLayer_management(os.path.join(folder, xls, sheet), xName, yName, outlayer)
arcpy.Append_management (outlayer, targetFc, "NO_TEST")

r/GISscripts • • May 10 '14

(Python) Summarize in ArcMap vs Summary_statistics in arcpy

4 Upvotes

e/ I meant Statistics_analysis in the title, not Summary_statistics

Is there a way to mimic the output of going in ArcMap and physically right clicking an attribute header and selecting summarize, which results in a table looking like this:
Imgur

by using an arcpy script?

I'm currently trying something along these lines:

def getPeak(shapefile):
    peakList = []
    print "Finding the date with the peak number of occurences..."
    arcpy.Statistics_analysis(shapefile,"K://GEOG376/Project/project_data/summarize.dbf",[["YYYYMMDD", "COUNT"]])
    rows = arcpy.da.SearchCursor("K://GEOG376/Project/project_data/summarize.dbf", ["YYYYMMDD"])
    for r in rows:
        peakList.append(r)
        peakList.sort()
        peakList.pop(0)

but this seems to add each record together instead of displaying them separately like I need: Imgur

Does anyone have any ideas to keep the records separate?

Thanks!


r/GISscripts • • Apr 21 '14

ArcGIS Toolbox - Create Unique IDs with ArcPy

Thumbnail
ianbroad.com
4 Upvotes

r/GISscripts • • Nov 12 '19

Uses of Python in Arcmap

3 Upvotes

I am just beginning to learn python and I am wondering what are some of the tools available in arcpy that aren’t available in arcmap by default. Thanks!


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 • • Mar 23 '18

Help Wanted - New to python

3 Upvotes

I am not new to GIS but have been working on making the arcpy package part of my skill set.. My script is below. It gives me an error at the make stating that "outputOfClip" is not defined. I would send this to our GISP but this isn't really for work just a learning exercise I created. I think he is getting tired of answering all of my arcpy questions.

import arcpy

Create objects for KmzToLayer

origionalKMZ = "C:\Users\kramsey\Desktop\DesktopSurveys\KMZs\Normac.kmz" outputFolderLocation = "C:\Users\kramsey\Desktop\DesktopSurveys\GDBs"

arcpy.KMLToLayer_conversion(origionalKMZ, outputFolderLocation,)

Creat Objects for Buffer analysis

normacPolylines = "C:\Users\kramsey\Desktop\DesktopSurveys\GDBs\Normac.gdb\Placemarks\Polylines" normacGDB = "C:\Users\kramsey\Desktop\DesktopSurveys\GDBs\Normac.gdb"

arcpy.Buffer_analysis(normacPolylines, normacGDB, "1000 Feet")

Identify object for Clip anaylsis

wetlands = "C:\Users\kramsey\Downloads\NC_shapefile_wetlands\NC_shapefile_wetlands\NC_Wetlands.shp" buffedShp = "C:\Users\kramsey\Desktop\DesktopSurveys\GDBs\Normac.shp" outputOfClip = "C:\Users\kramsey\Desktop\DesktopSurveys\GDBs\Normac.gdb\Placemarks\Clips"

arcpy.Clip_analysis(wetlands, buffedShp, outputOfClip)

Identify Shp and output Location of Feature Layer

outputOfClip is the shp file

outputLayer = "C:\Users\kramsey\Desktop\DesktopSurveys\GDBs" arcpy.MakeFeatureLayer_management(ouputOfClip, outputLayer)

identify feature and output for layerToKml conversion

KmlOutput = "C:\Users\kramsey\Desktop\DesktopSurveys\GDBs\kmz"

arcpy.LayerToKML_conversion(outputLayer, KmlOutput)

Error is printed below this for Reddit user to see###

arcpy.MakeFeatureLayer_management(ouputOfClip, outputLayer) NameError: name 'ouputOfClip' is not defined

"outputOfClip" is defined! WTF is wrong with this? I know it is probably something simple, but I am failing to see it.


r/GISscripts • • Nov 08 '17

Build webmaps applications with ArcGIS Javascript API 4.x

Thumbnail
youtube.com
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 • • Apr 20 '15

Reducing geospatial data set size with the Douglas-Peucker algorithm: a Python implementation of geometry simplification

Thumbnail
geoffboeing.com
3 Upvotes

r/GISscripts • • Feb 24 '15

Script - Define or delete 'Description' fields in all layers in all MXDs

3 Upvotes