|
POST
|
Hi Kevin, Tim is right about the number of bands which should be the same for all raster you want to mosaic together. The syntax of Mosaic To New Raster (Data Management) is this: MosaicToNewRaster_management (input_rasters, output_location, raster_dataset_name_with_extension, {coordinate_system_for_the_raster}, {pixel_type}, {cellsize}, number_of_bands, {mosaic_method}, {mosaic_colormap_mode}) In my script this is what is assigned: input_rasters = lstRas output_location = Input_Model raster_dataset_name_with_extension = "wse_100_Yr" {coordinate_system_for_the_raster} = "NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet" {pixel_type} = "32_BIT_FLOAT" {cellsize} = "3" number_of_bands = "1" {mosaic_method} = omitted {mosaic_colormap_mode} = omitted This was taken from your original settings. So you are executing a mosaic using a cell size of 3 and 1 band. Verify your input rasters. If the settings are not correct, change them in the script. If the number of bands in the rasters is not the same, you will not be able to mosaic them together. Kind regards, Xander
... View more
10-15-2013
10:37 PM
|
0
|
0
|
2339
|
|
POST
|
Hi Tim, This method will not give you a true distance of 1m. Each cell will have an 1x1m area and statistics will be based on all points within the area of a cell. Kind regards, Xander
... View more
10-15-2013
10:22 PM
|
0
|
0
|
1302
|
|
POST
|
I would like to advise against using a (3D) buffer methodology. LiDAR / LAS dataset tend to be very large when it comes to the number of points and LAS dataset are not a valid data type to use in these type of tools. Now you could convert your LAS data to a point featureclass, but determining for each point the number of neighbors in a 3D environment will take a long time to process. When you work with LiDAR data, use LAS tools to process them. In your case to get an impression of where "dense" areas are use the LAS Point Statistics As Raster (Data Management) tool. Use CELLSIZE as sampling type and 1 as sampling value to get the statistics per 1 m². There are several methods to choose from: PULSE_COUNT�??The number of last return points. POINT_COUNT�??The number of points from all returns. PREDOMINANT_LAST_RETURN�??The most frequent last return value. PREDOMINANT_CLASS�??The most frequent class code. INTENSITY_RANGE�??The range of intensity values. Z_RANGE�??The range of elevation values. There is also another Help topic on Estimating forest canopy density and height that provides some helpful information. Kind regards, Xander
... View more
10-15-2013
06:23 AM
|
0
|
0
|
1302
|
|
POST
|
Hi Margo, The visibility does not refer to a straight line through space between the observer and the target. The line follows the surface (the DSM) and determines for each point on the surface if the observer can see it. See image attached: [ATTACH=CONFIG]28334[/ATTACH] Green is visible, Red is not... Kind regards, Xander Some more reading: Understanding visibility analysis Creating a profile graph from line-of-sight results
... View more
10-15-2013
04:54 AM
|
0
|
0
|
747
|
|
POST
|
Hi Kevin, I hate to break the news to you, but there is a lot more wrong with the script then what Jim is mentioning. I'll mention a few points: You access the environment setting "env" before they have been initialized ("from arcpy import env" is missing) You set the workspace property of the environment setting using a variable "Input_Model", which is not available at that point, since it is obtained from the first parameter later in the script You use "gp.overwrite", but gp is not set (you should use the "env" for this purpose and set it properly). The overwrite property does not exist this should be overwriteOutput You check out a Spatial Analyst extension, but the tools you're using do not require the sa extension. You load the Data Management Tools toolbox, but this is really not necessary (was done in previous versions) You set a variable wse_grid equal to a hard coded string including " + Count", when you probably want to add the count to the string As mentioned before your first argument is read after its first use "Input_Model = arcpy.GetParameterAsText(0)" should move to the top You preform an "arcpy.ListRasters". This works on the current workspace. To do this for each folder, you should set the env.workspace for each folder Next you loop through the rasters with the statement for "wsgridp004" in rasters: This will not work. Normally you would use something like for raster in rasters: and then access the raster object in the following steps In the arcpy.Clipmanagement statement, you specify strings, when you should specify the variables. arcpy.Clipmanagement does not exits, it should be arcpy.Clip_management "FP_Poly" is specified as hard coded string, but should be specified as variable (without double quotes) Next you add a variable to the array with "array.add", but this variable is never set correctly (the initial wrong value is assigned multiple times) In the arcpy.MosaicToNewRaster_management you again specify hard coded strings, when you should specify variables (for instance Input_Model should be without quotes. The string "array.next" should be a list of rasters separated by semicolons. Since you obtain it from different workspaces, you should include the path for each raster To get you started I've included some code. The code however has not been tested... import arcpy import os from arcpy import env env.overwriteOutput = True # Argument 1 is the GeoRAS Directory Input_Model = arcpy.GetParameterAsText(0) # Argument 2 is the 100-Year Floodplain FP_Poly = arcpy.GetParameterAsText(1) Count = 0 lstRas = '' rasName = 'wsgridp004' # set workspace for list folders env.workspace = Input_Model Folders = arcpy.ListWorspaces("*", "Folder") for Folder in Folders: env.workspace = Folder #Find the wsgridp004 Raster rasters = arcpy.ListRasters(rasName , "GRID") for raster in rasters: Count += 1 wse_grid = Input_Model + os.sep + "{0}{1}".format(rasName ,Count) #Clip Raster with 100-Yr Floodplain Polygon arcpy.Clip_management(raster, "#", wse_grid, FP_Poly, "0", "ClippingGeometry", "NO_MAINTAIN_EXTENT") print arcpy.GetMessages() if lstRas == '': lstRas = wse_grid else: lstRas = lstRas + ";" + wse_grid #Mosaics Clipped 100-Yr Floodplain Grids print "Mosaicing Clipped Water Surface Grids" arcpy.MosaicToNewRaster_management(lstRas, Input_Model, "wse_100_Yr","NAD_1983_StatePlane_Texas_Central_FIPS_4203_Feet", "32_BIT_FLOAT", "3", "1") print arcpy.GetMessages() print "Complete" Assuming from the line where you load the toolbox that you are using ArcGIS 10.0 you should look into this topic: A quick tour of ArcPy The training.esri.com site offers some Python/arcoy courses that might be interesting: http://training.esri.com/gateway/index.cfm?fa=search.results&searchterm=arcpy&search=Search&CourseTypeID=1&ArcGISVersion=10.0 Kind regards, Xander
... View more
10-14-2013
11:52 PM
|
0
|
0
|
2339
|
|
POST
|
Hi Joseph, The field COSTPATH should give you the "cost" to travel to the destination. The cost will be presented by a value 0 when the pixel is shared by different paths. Kind regards, Xander Help 10.2: Creating the least cost path
... View more
10-14-2013
12:13 AM
|
0
|
0
|
393
|
|
POST
|
Hi, I have a dataset of 34 sites, and need to calculate the least cost path of each site to every other site in the dataset. I have managed to successfully run a model, however because I am using the same site input file for both site origin and site destination, the least cost path is each site to itself. Is there a quick way to tell arcgis to not calculate the distance of a site to itself? I am using arcgis 10.1. Any help would be greatly appreciated, as I don't want to create 33 dummy destination files, with each origin point removed. Thanks, Kat Hi Kat, It sounds to me that you could solve this by using an iterator to loop over field values. In that case you would be executing your model several times, with only changing source and destinations. Suppose you have a field with unique values (1 - 34) of your sources/destinations, then you can use the 'Iterate Field Values' for 33 times (skip the last). Each iteration will give you the value of a single source. By using this value in the definition query (UniqueValue = iterationValue) of the tool 'Make Feature Layer (Data Management)' you can create a source layer (not a physical file) that only contains this single location. Use the Make Feature Layer tool again with a different definition query (UniqueValue > iterationValue) to create the destination layer. Execute the cost distance with these layers. Some reading on iterators: A quick tour of using iterators Examples of using iterators in ModelBuilder Kind regards, Xander
... View more
10-13-2013
11:48 PM
|
0
|
0
|
967
|
|
POST
|
Hi Emil, The 3D GIS Development Team (3DGISTeam) has added a number of tools to help you with LiDAR data: http://www.arcgis.com/home/search.html?q=owner:3DGISTeam Have a look at the LAS Height Above Ground geoprocessing sample. This resource may be interesting too: Estimating forest canopy density and height There is also a white paper on "Lidar Analysis in ArcGIS 10 for Forestry Applications" (PDF) Kind regards, Xander Please note that LAStools (which is very powerful and can be integrated into ArcGIS) is not a free tool. If you want to use it for commercial use, you will need to obtain a license: http://rapidlasso.com/pricing/
... View more
10-11-2013
04:57 AM
|
0
|
0
|
9826
|
|
POST
|
Hi Gino, Additional to what Neil is showing you can determine the name of the Shape field by describing it: import arcpy
desc = arcpy.Describe(r'path to your featureclass')
fldNameShape = desc.shapeFieldName
Find more info about the describe properties of a Featureclass here: FeatureClass properties (arcpy) Another way of accessing standard fields (not determining the name though) is using tokens in for instance an arcpy.da.SearchCursor. Some examples are: SHAPE@ �?? A geometry object for the feature. SHAPE@AREA �?? A double of the feature's area. SHAPE@LENGTH �?? A double of the feature's length. OID@ �?? The value of the ObjectID field. You can find Python code examples here: SearchCursor (arcpy.da) Kind regards, Xander
... View more
10-11-2013
12:18 AM
|
1
|
0
|
1242
|
|
POST
|
Hi Alice, It sounds to me that the shapefile is not projected correctly. When you say: I've dropped a copy of the Shapefile in with a Projected Coordinate System of North Polar Stereographic for kicks, and that is visualized at the North Pole. ... did you create that shapefile by projecting (Data Management toolbox) the shapefile? If so we should look closer to the settings you've used. An important one is the optional Geographic Transformation. For good geoprocessing results (extraction of the rasters) the data should be in the same projection. Could you attach (part of) the original shapefile and a sample raster, so I can look into it? Some more reading: What are map projections? (Guide book) Georeferencing and coordinate systems Kind regards, Xander
... View more
10-10-2013
10:52 PM
|
0
|
0
|
981
|
|
POST
|
I am looking for a way to identify what layers have a selection in the TOC. I know this can be done in .NET. I have yet to see anything in python. If anyone can help let me know! Thank You, - B Hi Bob, It would be nice to have a short way of determining if a layer in the TOC has a selection (which is pretty straightforward with ArcObjects). I wrote a small piece of code and it seams to work as long as not all the features in a layer are selected: import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]
lyrs = arcpy.mapping.ListLayers(mxd, "", df)
for lyr in lyrs:
if lyr.isFeatureLayer:
# this is the number of (selected) features in layer in TOC (in DefQuery)
countSel = int(arcpy.GetCount_management(lyr).getOutput(0))
# when there is a defintionQuery test features in query against 'selected' feature
lyr2 = lyr.dataSource
if lyr.definitionQuery == '':
countDefQ = int(arcpy.GetCount_management(lyr2).getOutput(0))
else:
field = "OID@"
countDefQ =0
for row in arcpy.da.SearchCursor(lyr2, (field),where_clause=lyr.definitionQuery):
countDefQ+=1
# now test the counts
if countSel == countDefQ:
print "Layer '{0}' has no selection OR all features are selected".format(lyr.name)
else:
print "Layer '{0}' has a selection. CountSel={1} en CountDefQ={2}".format(lyr.name,countSel,countDefQ) I came across a much smaller snippet of Python code in an older post: import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")[0]
lyrs = arcpy.mapping.ListLayers(mxd, "", df)
for lyr in lyrs:
if lyr.isFeatureLayer:
selectionCount2 = int(arcpy.GetCount_management(arcpy.Describe(lyr).catalogpath).getOutput(0)) - int(arcpy.GetCount_management(lyr).getOutput(0))
if selectionCount2 == 0:
print "Layer '{0}' has no selection OR all features are selected".format(lyr.name)
else:
print "Layer '{0}' has a selection. Difference={1}".format(lyr.name,selectionCount2) The downside of this method is that it doesn't take the Definition Query into account. Maybe if both are mixed it can be done. I think this would be a nice feature to have in a next release... Kind regards, Xander Bakker
... View more
10-10-2013
12:59 AM
|
0
|
0
|
480
|
|
POST
|
Hi Tom, Jeffrey points out correctly the additional functionality offered by the pythonaddins module. However it will return the selected dataframe or layer. In case more than 1 layer is selected the result is None. This wouldn't work for your purpose. Kind regards, Xander Bakker
... View more
10-09-2013
11:00 PM
|
0
|
0
|
1805
|
|
POST
|
Hello~ I have a shapefile with lat/lons in decimal degrees which I want to use to extract the raster cell value, which is in meters. How can I convert the decimal degrees to meters, which is the geographical location of each raster cell? If I use the Info tool to query a point from the shapefile over the raster, Arc easily pulls the shapefile point and raster cell values. I want to be able to do this in arcpy and sync this raster cell value onto my attribute table. My shapefile is a time series of 45 days and I have daily rasters. I want to query each point to the corresponding raster to extract the appropriate cell value for the date and lat/lon of each point. Any help is appreciated! Thanks. Hi A Orlich, I assume your rasters are in a metric projection. If this is the case the easiest way of doing this is using the "Extract Multi Values to Points (Spatial Analyst)". The Help page shows Python code to do this. This tool adds the cell value at the point location for each raster. So for each raster an attribute (extra column) is created. Before you do this, be sure to project your point data to the coordinate system the rasters are using. Use the "Project (Data Management)". Again the Help page contains a Python script sample to do this. Kind regards, Xander Bakker
... View more
10-08-2013
10:47 PM
|
0
|
0
|
981
|
|
POST
|
Hi Tom, When accessing a layer you will not have information if the layer is selected or not. A map document does not need to be open to be accessed by Python code. That's why there is no "selected" property on layers. Instead you may want to use the "visible" property of the Layer (arcpy.mapping) object. This enable you to detect whether the layer is switched on or off. Layer.visible: Controls the display of a layer. This has the same effect as checking the check box next to the layer in the table of contents in ArcMap. If set to True, the layer will draw; if set to False, the layer will not be drawn. Not all layers support the visible property (for example, restricted web service layers), so it is good practice to test for this ahead of time using the supports method. Kind regards, Xander Bakker
... View more
10-08-2013
06:06 AM
|
0
|
0
|
1805
|
|
POST
|
Hi Philip, Performing an IDW on 12 sample points is not very much. As the Help (IDW Spatial Analyst) states: The best results from IDW are obtained when sampling is sufficiently dense with regard to the local variation you are attempting to simulate. There is no limit in the minimum number of point. There is a limit when it comes to the maximum number of points: This tool has a limit of approximately 45 million input points. See also the Help topic How IDW works I just did a test with default settings on 12 random points and it worked (using 10.2). See screen shot: [ATTACH=CONFIG]28120[/ATTACH] Can you indicate the settings you're using and/or can you attach the dataset you're using? That makes it easier to determine the cause. Kind regards, Xander Bakker
... View more
10-08-2013
05:50 AM
|
0
|
0
|
1187
|
| Title | Kudos | Posted |
|---|---|---|
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM | |
| 1 | 05-29-2019 02:45 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-26-2025
02:43 PM
|