Tag Info

Hot answers tagged

9

Here is a simple approach using the built-in Python .isdigit(), .isalpha() and .zfill() methods. This approach uses the Python parser. Pre-logic Script Code: def changeAddress(y): integer = ''.join(x for x in y if x.isdigit()) string = ''.join(x for x in y if x.isalpha()) final = integer.zfill(3) return final + string ...


7

You should not bother using Describe to describe the path to the feature class first and then describing the geodatabase itself to find out whether it is personal or file one. I recommend using the AddFieldDelimiters arcpy function which will find out the data source and use proper syntax. This means that whatever the source you will use, you will always ...


6

Use the dataSource attribute for the layer. for lyr in arcpy.mapping.ListLayers(mxd): dataSource = lyr.dataSource if ".gdb" in dataSource: # your pseudocode "if database = GDB:" print "GDB {}".format(dataSource) elif ".mdb" in dataSource: print "MDB {}".format(dataSource) else: print "OTHER"


5

Yes, there is a way to do that. In the symbology palette for the overlay raster, you can select the Display Background Value (R, G, B) _ _ _ as ___ option (see screenshot for a raster I have doing the same thing with a white background. Assuming your background image is truly all white, your values will also be 255, 255, 255 in the boxes. Make sure to select ...


5

A shapefile (.shp) is a vector data storage format for storing the location, shape, and attributes of geographic features. A shapefile is stored in a set of related files and contains one feature class. A layer file (.lyr) is a file that stores the path to a source dataset and other layer properties, including symbology. In comparison to a shapefile, a ...


5

The Arc Select by location tool does not work so well for buffer analysis if your data is not projected (WGS 1984). It will draw the resulting buffer as a perfect circle shape, instead of a ovular shape by default (Euclidian vs. Geodesic). The circle does not represent distances accuratly because it does not take into account the curvature of the earth, and ...


5

The following approach uses a Search Cursor and Python dictionary to perform the following workflow: Select points within each polygon feature Update dictionary with key (OID) and value (point count) for each iteration Find max point value and corresponding OID and write to a text file import arcpy, os points = r'C:\temp\mytest\points.shp' polys = ...


5

I can crush this down to 3 lines of code, no cursors required! import arcpy arcpy.SpatialJoin_analysis("Site", "points","in_memory/points_SpatialJoin", "JOIN_ONE_TO_MANY", "KEEP_ALL", "", "INTERSECT") arcpy.Statistics_analysis("points_SpatialJoin", "in_memory/stats", "Join_Count SUM","Id") Then simply sort the table to find the polygon with most points.


4

The term "SRID" is overloaded in the GIS realm. In most contexts it refers to the coordinate reference system (CRS) of spatial data, but in Esri use, it really does refer to the spatial reference system, which is a combination of CRS with the X, Y, Z, and M offsets, X/Y, Z, and M scaling factors, the precision (HIGH or BASIC), the cluster tolerances (which ...


4

Another option is to get the file extension with the python os module. import os gdb = "C:/filepath/mygdb.gdb" path, ext = os.path.split(gdb) if ext == ".gdb": do somethings elif ext == ".mdb": do something else. path is "C:/filepath/mygdb", ext is .gdb


4

hillshade is based on the angle between the normal to the slope face and the sun rays. This angle is in a 3D space, so different combination of slope and aspect give the same value (like a cone with the sun ray for axis). In winter and in summer, both the sun elevation and the sun azimuth can be different at the same hour of the day. So you can have ...


3

You can certainly use FME to wrangle the XML and write it to a database. Something for you to understand first is that GIS like flat data with rows and columns, including geometry. XML is not flat, it is a (maybe big) hierarchical tree, which is a fundamentally different data model than most GIS formats. That said, you can parse the XML and extract all the ...


3

You can block out the "white" using a Mask function, through the image analysis window. Change NoData Interpretation to "All", and add values 0 (minimum) and 250 (maximum) to all bands in your raster. As your image may contain "near white" values, you may want to lower the masking threshold to, say, 245. The "white" values will also depend on the pixel depth ...


3

Sorry,My English is not so good.But it may be useful to you. You can use [Make Query Table] Tool in ArcToolBox: Add feature class and table to the input table. Select the required field in the field list(eg.table.trip,table.datetime...),Most important point is you must select your featrue class's shape field too. If you forget it,the result be a TableView ...


3

Have a look at this bit of code as your fieldB is of type string it does not need to do any type conversion. This bit of python goes in the code block: def numonly(s): if s.isdigit(): return s else: return ""


2

Reading through the answer to this question may help you: http://stackoverflow.com/questions/20601997/how-to-approach-converting-vbscript-to-python-code Break down the labeling script into its parts (variables, functions, etc.) and then write that in pseudo-code. Since you are not familiar with JavaScript syntax, the Esri Help is a good place to start: ...


2

You're better off mosaicing first. It will save you time and effort to do so. Setting up a batch process in general usually takes a bit more time than firing off a single calculation on a single raster. This is especially true in ArcGIS, whose batch tools aren't always user friendly and are sometimes completely separate geoprocessing tools from the ...


2

The trick to doing this is to first create a legend style item either in your user style file or in a custom style file. For the sake of simplicity, I'll show you how to do it using your user style. In ArcMap, go to Customize > Style Manager You should see a folder in the Style Manager which references the user style file ArcGIS auto-creates to store all ...


2

I do this a lot with historic maps, and began by using @nicksan's method, but had the same issues the OP mentioned. I haven't used the mask method (will try soon) but here's what I do now, if you can deal with not having the red and blue in your overlay: Make sure you have Updated Georeferencing in the georeferencing toolbar and then remove the layer from ...


2

There are several ways to calculate this, one is using regexp with Python: expression: value(!f!) code block: def value(f): import re if len(re.findall(r'\d', f)) ==1: return "00{}".format(f) elif len(re.findall(r'\d', f)) ==2: return "0{}".format(f) else: return f


2

If you work with an enterprise geodatabase stored in any DBMS supported, you could use SQL TOP query. I'd just create a copy of the layer in the TOC and then setup the definition query for that layer (Layer Properties > Definition Query tab), but you could also use this syntax directly in the Select By Attributes dialog. Meters in (select top 10 [Meters] ...


2

According to this page the spatial rel enum for intersect: Returns a feature if any spatial relationship is found. Applies to all shape type combinations. and for overlap: Returns a feature if the intersection of the two shapes results in an object of the same dimension, but different from both of the shapes. Applies to Area/Area, Line/Line, ...


2

MapControl is an engine component to create your own window to display map contents. I've looked before and never found a way to get a reference to the ArcMap MapControl. ArcMap may not even use a MapControl for its display, it may use some other internal class. Two options: 1) var ave = ActiveView as IActiveViewEvents; ave.AfterDraw += onAfterDraw; ...


2

I am posting the code which should fulfill your requirement (based on my understanding of your requirement). Please change accordingly if required. # required import import arcpy # path of Points_lyr feature class/table (point) point_fc = r'D:\Python\ScratchDatabase\Geodatabase.gdb\Point' # related fields #first field 'MEAS' to compare and second field ...


2

You will need to go back to your imagery provider and get imagery from an earlier (or later) date which is cloud free Mapbox provides cloud free imagery but as it is merged from lots of different photo's you can't use it for analysis and I don't know how much it costs https://www.mapbox.com/data-platform/


2

Convert the featureLayers renderer to JSON. Then use the JSON to create a new renderer. var featureLayerRenderer = featureLayer.renderer.toJson(); var renderer = esri.renderer.fromJson(featureLayerRenderer);


2

There should be essentially no difference. I don't know quite how to clearly explain this, but when re-projecting, you are in fact re-sampling at the same time, even if your cellsize were to remain the same. In order to project, the projection algorithm has to know where to 'place' the data, i.e., it has to have a location to project each cell value to, ...


2

You should use the "Group Analysis" tool to achieve your goal. This tools is a great tool from "spatial statistics" toolbox as @phloem pointed to. However you should fine tune the tool to adapt to your data and problem. I created a similar scenario like the one you posted and got the response close to your goal. Hint: Using ArcGIS 10.2, when I ran the tool, ...


2

Original set: Create pseudo-copy (CNTRL-drag in TOC) of it and make spatial join one to many with clone. In this case I used distance 500m. Output table: Remove records from this table where PAR_ID = PAR_ID_1 - easy. Iterate through table and remove records where (PAR_ID,PAR_ID_1 )=(PAR_ID_1, PAR_ID) of any record above it. Not so easy, use acrpy. ...


2

I would suggest using a couple of definition queries. these will allow you to have different layers in your table of contents that all draw from the same data. so if you had an attribute called type with values lateral and main you could set one query to "type" = 'main' and set the color ramp (or ranges) while the other would be "type" = 'lateral' and would ...



Only top voted, non community-wiki answers of a minimum length are eligible