|
POST
|
So, now I have a different problem. I am trying to use 'feature vertices to points' for another feature and I have 24,755 lines, but it gives me both 93,540 begin and end points. I took a look at the situation by selecting generated startpoints with the same objected and the related line, so I can see what the situation is (see attached screenshot), but I don't know how to deal with this. If I determine the DEM at these points, how would I again couple it to a line to create a 3D model by attributes? Ideas? Hi Erin, It looks like your lines may be multiparts. I have seen this at a client who manages 3D pipelines. In some causes this can be caused by individual segments dissolved together, but due to opposite directions of individual segments, a multipart is created. You could verify this by going into Edit mode, select the feature, choose Edit Vertices and open the Edit Sketch Properties window. Another alternative is to create new field in the line featureclass and calculate (using Python syntax): !Shape!.partCount This can (sometimes) be corrected by using the "Dissolve (Data Management)" tool, with the UNSPLIT_LINES option switched on. (Lines are only dissolved when two lines have an end vertex in common). The create multipart features option should be off. Kind regards, Xander
... View more
11-20-2013
01:39 AM
|
0
|
0
|
2215
|
|
POST
|
Hi Sam, In your case it would be better to use polygons with a single height linked to it. If you look at the Help topic "Fundamentals of creating TIN surfaces" you will see at the Polygon surface feature types section: Replace polygons set the boundary and all interior heights to the same value. A replace polygon could be used to model a lake or an area on a slope excavated to a level surface. ... which is what you want. If you look at the explanation of "Hard breaklines" in the section Breaklines and hulls, you will see: Hard breaklines represent a discontinuity in the slope of the surface. Streams and road cuts could be included in a TIN as hard breaklines. Hard breaklines capture abrupt changes in a surface and improve the display and analysis of TINs. See also this topic on Breaklines in surface modeling which visually explains how breaklines work. Kind regards, Xander
... View more
11-19-2013
10:30 PM
|
1
|
0
|
4478
|
|
POST
|
Hi Michael, The DBAs (and you) are right; data duplication creates a lot of extra work (apart from the additional data storage). Maybe in the future we'll see some extra functionality in ArcGIS allowing us to create attachments in the form of "hyperlinks" to existing data. I see two ideas that kinda want the same as you're proposing: Geodatabase Attachments for large organizations Geodatabase Attachments Storage Location Option I think we should promote those ideas. Kind regards, Xander
... View more
11-18-2013
04:22 AM
|
0
|
0
|
1834
|
|
POST
|
I have a continuous raster and a set of polygons that overlap the raster. Does anyone know of a method to: 1) identify the maximum value of the raster within each polygon 2) extract the cells associated with these maximum values and store as a separate raster (or points) Any suggestions are greatly appreciated. Hi Todd, Try this: Perform a Zonal Statistics (using the polygons as zones, the raster as values and MAXIMUM as stistics type) Calculate a boolean raster with: ValueRas = MaxRas (value 1 will indicate those pixels locations with maximum value in polygon) Use the SetNull to obtain a raster holding only the maximum values at the locations you're interested in and rest NoData: OutRas = SetNull(BooleanRas, MaxRast, "Value = 0") Convert this "OutRas" to points Kind regards, Xander
... View more
11-18-2013
02:15 AM
|
0
|
0
|
7684
|
|
POST
|
Muchas gracias Xander. tendré muy presente tu sugerencia en escribir en el foro en español o hacerlo en inglés, que es lo mejor. He leído el post y la info que incluyes, y entiendo que para ejecutar scripts de python desde tareas la solución es hacerlo como administrador. Es correcto? Hola Angel, Creo que lo más importante es la marca de verificación "Run with the highest privileges" (ejecutar con los más altos privilegios) que debe ser prendido. Si puedes correr el script manualmente desde una cuenta específica (administrador), todavía en la definición de la tarea, se requiere que la opción "ejecutar con los más altos privilegios" este prendida. Saludos, Xander
... View more
11-17-2013
11:40 PM
|
0
|
0
|
944
|
|
POST
|
Would you be able to extend your code in python to be able to access images already stored as a BLOB field in SQL Server 2012 (non-GIS) as attachments without having to copy the images into ESRI feature classes thus eliminating data duplication of attachment files? Hi Michael, Could you explain this a little more? Do you have images stored in SQL Server 2012, and you want to use them as attachment, without the need to convert them to an Esri attachment table? If that's the case, I don't think ArcGIS will recognize them as attachments. If you would like to extract the BLOB attachments stored in SQL Server 2012 by code, I think you should be able to do so. If the SQL Server 2012 table can be accessed by ArcGIS, you can loop through it and extract the attachments (like in the code, save it to disk). After saving the files to disk, I guess you can use "Generate Attachment Match Table (Data Management)" and Add the attachments (which would duplicate or "triplicate" the data). More on this in the Help topic "Working with the Attachments geoprocessing tools". Not sure, if this is the answer you are looking for. Kind regards, Xander
... View more
11-17-2013
10:06 PM
|
0
|
0
|
1834
|
|
POST
|
How would I go about added the relationship data into my python script. "If you want to access the feature itself, you will have to use the "REL_OBJECTID" field from the attachment table and query the featureclass on OBJECTID = REL_OBJECTID..." I know you mentioned this way, but since it is a relationship does it need to be pathed to a geodatabase? Or how does it pull the relationship information with the pictures? Hi Nicholas, If you would like to access the related information the belongs to the attachment, you will have to use the REL_OBJECTID in the attachment table to query the feature class. In the code below I created a function "QueryRelatedData" that retrieves information from the feature class. If the related OID = 2, the expression will be "OBJECTID = 2", which is used as a query definition to only extract 1 feature. Next the attribute in the field "SomeFieldInFeatureClass" is accessed and returned. I didn't test the code below, so be careful. def main():
global arcpy
import arcpy, os
# fixed settings
fldBLOB = 'DATA'
fldAttName = 'ATT_NAME'
fldRelOID = 'REL_OBJECTID'
# your settings (edit these)
fc = r"C:\Project\_LearnPython\Attachments\test.gdb\Meldingen"
tbl = r"C:\Project\_LearnPython\Attachments\test.gdb\Meldingen__ATTACH"
outFolder = r"C:\Project\_LearnPython\Attachments"
fldRelatedInfo = 'SomeFieldInFeatureClass' # should be valid column in FC
with arcpy.da.SearchCursor(tbl,[fldBLOB,fldAttName,fldRelOID]) as cursor:
for row in cursor:
binaryRep = row[0]
fileName = row[1]
relOID = row[2]
# access related information
myRelatedInfo = QueryRelatedData(fc, fldRelatedInfo, relOID)
# do something with the related info
# save attachment to disk
open(outFolder + os.sep + fileName, 'wb').write(binaryRep.tobytes())
del row
del binaryRep
del fileName
def QueryRelatedData(fc, fldRelatedInfo, relOID):
fldOID = 'OBJECTID'
expression = arcpy.AddFieldDelimiters(fc, fldOID) + " = {0}".format(relOID)
with arcpy.da.SearchCursor(fc, (fldOID, fldRelatedInfo), where_clause=expression) as cursor:
for row in cursor:
return row[1]
break
del row
if __name__ == '__main__':
main()
Kind regards, Xander
... View more
11-17-2013
09:55 PM
|
0
|
8
|
3928
|
|
POST
|
Hi Scott, ArcGIS 10.2 still comes with a python script tool in the Server Tools\Data Extraction: Send Email With Zip File Attachment. It uses the old arcgisscripting.create(9.3), but shows how you can send email with Python code. import arcgisscripting, smtplib, os, sys, traceback
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
gp = arcgisscripting.create(9.3)
#**********************************************************************
# Description:
# Emails a file. File is assumed to be a zip file. Routine either attaches
# the zip file to the email or sends the URL to the zip file.
#
# Parameters:
# 1 - File to send.
# 2 - Email address to send file.
# 3 - Name of outgoing email server.
# 4 - Output boolean success flag.
#**********************************************************************
def send_mail(send_from, send_to, subject, text, f, server, smtpUser="", smtpPwd=""):
try:
msg = MIMEMultipart()
msg['From'] = send_from
msg['To'] = COMMASPACE.join(send_to)
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach( MIMEText(text) )
part = MIMEBase('application', "zip") # Change if different file type sent.
part.set_payload( open(f,"rb").read() )
Encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(f))
msg.attach(part)
smtp = smtplib.SMTP(server)
# If your server requires user/password
if smtpUser != "" and smtpPwd != "":
smtp.login(smtpUser, smtpPwd)
smtp.sendmail(send_from, send_to, msg.as_string())
smtp.close()
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + \
str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"
raise Exception("SendEmailError:" + pymsg)
if __name__ == '__main__':
sendto = gp.GetParameterAsText(0).split(";")
fromaddr = gp.GetParameterAsText(1)
subject = gp.GetParameterAsText(2)
text = gp.GetParameterAsText(3)
zipfile = gp.GetParameterAsText(4).replace("\\",os.sep)
maxsize = int(gp.GetParameterAsText(5)) * 1000000
smtpMailServer = gp.GetParameterAsText(6)
smtpUser = gp.GetParameterAsText(7)
smtpPwd = gp.GetParameterAsText(8)
try:
zipsize = os.path.getsize(zipfile)
#Message"Zip file size = "
gp.AddMessage(gp.GetIDMessage(86156) + str(zipsize))
if zipsize <= maxsize:
send_mail(fromaddr, sendto, subject, text, zipfile, smtpMailServer, smtpUser, smtpPwd)
#Message "Sent zipfile to %s from %s"
gp.AddIDMessage("INFORMATIVE", 86154, sendto, fromaddr)
gp.SetParameterAsText(9, "True")
else:
#Message "The resulting zip file is too large (%sMB). Must be less than %MB. Please
# digitize a smaller Area of Interest."
gp.AddIDMessage("ERROR", 86155, str(round(zipsize / 1000000.0, 2)),
str(round(maxsize / 1000000.0, 2)))
gp.SetParameterAsText(9, "False")
raise Exception
except:
# Return any python specific errors as well as any errors from the geoprocessor
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + \
str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"
gp.AddError(pymsg)
#Message "Unable to send email"
#gp.AddIDMessage("ERROR", 86157)
gp.AddError("ERROR, Unable to send email") Kind regards, Xander
... View more
11-15-2013
12:16 AM
|
0
|
0
|
2532
|
|
POST
|
Now I have a point file with the absolute depths of the end points of the pipes in one field of the attribute table and a seperate line file of the pipes. Feature to 3d by attribute has a "to" and "from" option, but I would need to use the lines as input features and add the to and from values from the points to the attribute table of the lines (and I'm not sure how to approach that problem). However, it seems like there *should* be a tool to create a 3D layer from the lines using the depths at the locations of the points (kind of like how you would derive the z values for surface features from a DEM). Any ideas? Hi Erin, What method did you use to obtain the height at the end points? Do you also have the height at the "from" points? If feature vertices to points was use, did you use the BOTH_ENDS setting? The idea is to have a point feature class with the location of both the from and the to point, or have two feature classes (one with the from and the other with the to points). Extract the raster values using the point feature class(es). Next step would be to join the point feature class through a common field back to the lines. That way you will have the from and to height of each pipe. Use this information to use the tool "Feature to 3d by attribute" with the "to" and "from" option. Kind regards, Xander
... View more
11-14-2013
11:58 PM
|
0
|
0
|
2216
|
|
POST
|
Hola Angel, Primero que todo, cuando tengas una pregunta en este foro se recomiendo hacerlo en inglés. Hay un foro especialmente en español aquí: http://forums.arcgis.com/forums/50-Español Para no frustrar tu búsqueda de una respuesta útil, me suena que esto puede ser un problema que los privilegios no son suficientes. Hay un "thread" donde se discute las posibles causas porque no sea posible ejecutar un tarea (es en inlgés): http://forums.arcgis.com/threads/51834-python-script-performing-oddly-when-run-as-a-scheduled-task-on-windows-server Algo de información adicional sobre este tema: With the UAC, users of the admin group have 2 tokens. The filtered token represents standard user rights. This token is used to create the shell. So you have standard user rights. When you click an executable and select "run as administor", the full token is used which contains admin rights. When you now configre Task scheduler and select "Run with the highest privileges", the full token (admin rights) is used. This only works if the user is in the admin group, because only those users have 2 tokens. When you want to run a programm with admin rights from a standard user account, you have to select "run whether the user is logged on or not" and select a user which is member of the admingroup. Suerte, Xander
... View more
11-14-2013
11:35 PM
|
0
|
0
|
944
|
|
POST
|
Hi I am new to spatial analyst (I have ArcMap 10.1) and raster files 😕 I'm trying to create a percent slope polygon. I have a polyline shapefile of contours with an elevation field. I'm not sure what is the more accurate way to convert that to a Raster, (Topo to Raster, Feature to Raster, or Polyline to Raster) or if it even matters? The results vary. Once I have that Raster file I am able to calculate slope easily enough using the Spatial Analyst --> Surface-->Slope tool although then I cannot convert this Raster slope to a Polygon (Conversion Tools --> Raster to Polygon). Thanks! Kait Hi Kait, With respect of translating your contourlines to raster; the only correct way to obtain a DEM (Digital Elevatiuon Model) is to interpolate the data. Feature to raster and polyline to raster will not do that. These tools will simply assign a value of the contour to the cell, but in flat areas (where there will be less or no contour lines) this will result in NoData. So use Topo to Raster only for this purpose. You could read the Help topic on "How Topo to Raster works". It states: The Topo to Raster tool is an interpolation method specifically designed for the creation of hydrologically correct digital elevation models (DEMs) I see you were able to create the slope (the method you describe is correct), but were not able to translate the raster (floating grid) to polygons. The reason is that a raster with decimal value (floating) cannot be translated to polygons. Only Integer raster are allowed in this process. Normally the raster is first classified and then converted to polygons. See the topic on "Reclass by ranges of values" which uses the tool "Reclassify (Spatial Analyst)". The result is an integer raster which can be converted to polygons. In case you don't want to classify the data, you could convert it to integer (it will truncate the values) and then convert to polygons. If you can explain what you wish to obtain, I'm sure we can recommend which way to go. Kind regards, Xander
... View more
11-14-2013
10:56 PM
|
1
|
0
|
3239
|
|
POST
|
Thank you Mark, for clarifying that one simply cannot obtain the discharge from a DEM and providing insights on how this should be done. +1 for that. I guess I should have mentioned more clearly in my first post that it isn't possible to calculate the discharge applying a flow accumulation on the DEM. Kind regards, Xander
... View more
11-14-2013
10:40 PM
|
0
|
0
|
7343
|
|
POST
|
Hi Matthew, That is correct. The expression "Con(IsNull(myraster) ,0 ,1)" will create a binary output with only 0 and 1 values. This should only be used if you are interested in the number of rasters that have information at a cell. In your case your would have to use "Con(IsNull(myraster) , 0 , myraster)". This creates an output where NoData is replaced by the value 0. Please note that if you would add rasters that hold NoData (NULL) values, that the result of a sum will be NoData, regardless of other rasters that may have values defined for that pixel. See also: NoData and how it affects analysis Kind regards, Xander
... View more
11-14-2013
05:27 AM
|
0
|
0
|
1730
|
|
POST
|
Duplicate thread. See answer on Spatial Analyst forum: http://forums.arcgis.com/threads/96796-Determine-Floodplain-Based-on-known-flood-level Xander
... View more
11-14-2013
03:04 AM
|
0
|
0
|
348
|
|
POST
|
I have delineated a river centreline and interpolated the Z values from a DEM (SRTM 90m) to generate a 3D polyline that represents the river centreline. I have then adjusted the Z values within the 3D river centreline and increased it by 20m and 40m respectively. I've tried to use Visibility Analysis tool to try to generate the floodplain, but the results aren't great even after adjusting the vertical, horizontal and radius parameters. Any alternative would appreciated. So as explained, I'm trying to delineate the expected inundated surface areas coarsely from the river centreline, based on an adjusted Z value, then trying to determine the horizontal impact area of the DEM that is covered by water. Regards I came across a nice post where William Huber (Esri forum senior member and MVP) wrote about simulating a flood: http://www.quantdec.com/SYSEN597/studies/flood/index.htm It's an interesting article and I recommend you to read it. He also included an avenue script to calculate the change in flood plains over time. I translated this into a small python script (10.x) and it seems to works. William uses for his demo area (relatively flat) the following settings: nSourceElevation = 200 nFloodMax = 205 nIncrement = 0.25 nExtent = 200 In my case I used a more mountainous area, so the values area different. Investigate your data to see what setting fit your needs. This is what resulted, before: [ATTACH=CONFIG]29100[/ATTACH] and after: [ATTACH=CONFIG]29101[/ATTACH] #-------------------------------------------------------------------------------
# Name: SimulateFlood.py
# Purpose: Simulate a Flood
#
# Source: William A. Huber (Quantitive Decisions)
# http://www.quantdec.com/SYSEN597/studies/flood/index.htm
#
# Created: 14-11-2013
#-------------------------------------------------------------------------------
def main():
import arcpy,os
arcpy.CheckOutExtension("Spatial")
arcpy.env.workspace = r'C:\Project\_Forums\Flooding\fgdb\testflooding.gdb'
source = r'C:\Project\_Forums\Flooding\fgdb\testflooding.gdb\source' # The source water body (raster)
dem = r'C:\Project\_Forums\cost\fgdb\test.gdb\elevutm16n' # The elevation DEM (raster)
floodname = r'C:\Project\_Forums\Flooding\fgdb\testflooding.gdb\Flood_' # outputs
# settings
nSourceElevation = 100 # The elevation corresponding to the source body
nFloodMax = 400 # The maximum flood elevation; must not be less then nSourceElevation
nIncrement = 20 # The flooding elevation increment
nExtent = 750 # Do not flood outwards more than this many cells.
nTiny = 0.9/nExtent # Used for limiting flood extents
sourceRas = arcpy.Raster(source)
demRas = arcpy.Raster(dem)
steps = int((nFloodMax - nSourceElevation) / nIncrement) + 1
for i in range(0,steps):
xElevation = (i * nIncrement) + nSourceElevation
outname = "{0}{1}".format(floodname,i)
cost = (demRas > xElevation)+nTiny
costdist = arcpy.sa.CostDistance(sourceRas, cost, "#", "#")
flood = costdist <= (nExtent*nTiny)
if arcpy.Exists(outname):
arcpy.Delete_management(outname)
flood.save(outname)
sourceRas = arcpy.sa.Log10(outname) # Converts 1 to 0, 0 to NoData
del cost, costdist, flood
print "ready..."
if __name__ == '__main__':
main() Kind regards, Xander
... View more
11-14-2013
02:54 AM
|
0
|
1
|
2906
|
| 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
|