Quantcast
Channel: Question and Answer » arcgis-10.3
Viewing all 155 articles
Browse latest View live

Listing Data sources using arcpy: ListLayers very slow

$
0
0

What I am trying to do is create a list of all the data sources in a directory filled with mxds.
So I have this code pasted below. For some reason when listing layers it can take up to 50 minutes even though the mxd only has around 10 or 15 layers. Is this a common occurrence with the listlayers method?

with open('data.csv', 'wb') as csvfile:
fieldnames = ['File_Path', 'File_Size(MB)', 'Last_Edit', 'MXD_Version', 'Author', 'PageSize', 
              'XMAX', 'XMIN', 'YMAX', 'YMIN', 'DATASOURCE'] #all the header fields
writer = csv.DictWriter(csvfile, fieldnames = fieldnames)
writer.writeheader()
for mapDocument in findFiles(r"W:/GIS (no purge)", '*.mxd'):
    print mapDocument
    st = os.stat(mapDocument)
    print "Using ArcPY Mods..."
    mxd = arcpy.mapping.MapDocument(mapDocument) #using arcpy to gather more information
    print "Reading Map Document..."
    writer.writerow({'File_Path' : str(mapDocument),
                     'File_Size(MB)' : str(((st[ST_SIZE])/1024.0)/1024.0), 
                     'Last_Edit' : str(time.ctime(st[ST_MTIME])), 
                     'MXD_Version' : getMXDVersion(mapDocument)})

    print "Searching Layers and Writing..."
    for layer in arcpy.mapping.ListLayers(mxd):
        print "boop"
        if layer.supports("DATASOURCE"):
            writer.writerow({'DATASOURCE' : layer.dataSource})
        else:
            break
    del mxd

So my issue with the above code is when I am running it It will take forever to get to the ‘print "boop"‘but once it gets there it runs perfectly fine. It seems to get hung up at the arcpy.mapping.ListLayers(mxd) for a very long time.

Sometimes its great, only takes a few seconds, other times 8 minutes. That is manageable, but when I leave my code running all night and some of them take 50 minutes or it just crashes, that is the problem (it crashed due to a memory error). These mxds do not have that many layers in them either.

There is usually just one data frame that has at the most 20 layers in them. I can open these mxds myself and it only takes a few minutes at the most when i do.

From further testing it doesn’t seem to be related to the amount of layers either. There were a few mxds that had around 30 layers that were completed in a few seconds and then another few that took 4 hours (it had 44 layers) and there are some that had 30 layers and took 50 minutes. If I could just pinpoint why it takes so long it would be great.


ArcMap 10.3 – Anything Python related causes crash to desktop

$
0
0

Problem: ArcMap crashes to desktop anytime I use a Python related function (Toolboxes, Field Calulator, Etc)

How I got to this point: I was trying to gain some familiarity with Python programming and opted to use the guide of Learn Python The Hard Way.
This involved downloading, installing Python and setting your environment using Powershell.
I believe this caused some issues since there was already an installation of Python in effect from having ArcGIS Installed. There was already a “Python27″ folder on my main HDD.

Question: How do I tell my ArcMap to look in the “Python27ArcGIS10.3″ folder for Python? I’d prefer to avoid re-installing ArcGIS entirely.

Screenshots for thought:
enter image description here
^ From initial research, I found that I should have some sort of Python directory entered into these fields, but I’m not sure what specifically needs to go in there.

enter image description here

find all the null records for all fields in a shape file

$
0
0

I figured out that I can use field calculator on a single column in arcgis 10.3 attribute window as follows:

def RemoveNULL(x):
    if x is None:
        return ''
    elif x == '':
        return '0'
    else: return x

RemoveNULL(str(!myxField!))

What I really want to do is find a way to find all the null records for all fields in a shape file that are NULL (truely empty or ”) and change them to zero but preserve all other values (double or int numeric). I don’t care about text.

How can I install Pywin32 with the ArcGIS 10.3 python 2.7?

$
0
0

After installing Python2.7 with ArcGIS Desktop 10.3 and installing pywin 2.7 32bit as Administrator (very important!), I got the following error message:

close failed in file object destructor: sys.excepthook is missing lost        

sys.stderr

Is this important, or will I experience problems later?

Moving a Map Service Group Layer out of a Group Layer with ArcPy

$
0
0

I am struggling to move web services (tiled basemaps) out of group layers into the data frame. I’ve used arcpy.mapping.ListLayers to compose a list of layers, then I’ve ascertained what is a group layer with .isGroupLayer and I’ve tested the group layers name and then what it “supports”. However I failed miserably to pick up weird web service group layer and move them. I’ve tested arcpy.mapping.AddLayer among a handful of things.

Any ideas are welcome. My desired outcome is to have no web services in group layers.

enter image description here

import arcpy
mxd ="C:\Data\native.mxd"
OriginMxd = arcpy.mapping.MapDocument (mxd)
df = arcpy.mapping.ListDataFrames(OriginMxd)[0]

for OPFSLyr in arcpy.mapping.ListLayers(OriginMxd, "", df):
    if str(OPFSLyr) == "Basemap": # if  it's named basemap
        if OPFSLyr.isGroupLayer:
            for subLayer in OPFSLyr:
                print subLayer
                arcpy.mapping.AddLayer(df, subLayer, "BOTTOM")
                OriginMxd.save()

Changing Mosaic Dataset Properties in Map Document using ArcPy?

$
0
0

Does anyone know if it is possible in ArcGIS 10.3 for Desktop to access and change mosaic dataset properties within a map document using ArcPy?

I am trying to write text into the symbology description in the boundary layer of a mosaic dataset (not the description field on the layer properties general tab of the mosaic dataset).

Identify connected pipes that have the same attribute values [on hold]

$
0
0

I’m hoping that someone might be able to point me in the right direction with a little exercise I need to carry out. I work for a water utility customer and I have recently implemented a new GIS within the organisation. We are using ESRI (ArcMap v10.3.1) with ArcGIS for Server Basic Standard Version. We also have the Data Interoperability extension.

We are looking at changing our connectivity rules and hopefully retrospectively cleaning up our existing data to match these rules.

Does anybody know of a way that I could either set up some model builder queries (I haven’t gotten into python yet) that will allow me to identify connected sections of pipe that have the same attribute values such as install date, diameter, material or pressure rating? I would ideally like to then merge these features together in such a way that it creates a new feature in my database (this will automatically assign it a new ID from the triggers that we have set up in the database) but also copies the old original ID’s into some OLD ID fields that I will set up in against these featureclasses. I can do the sorting out of the ID’s further down the track, my priority is being able to identify the connected sections of pipes that have the same attribute values.

I’ve just started to dabble in SQL so I’m quite happy to have a look at ways that this could potentially be done at the backend database level if this is an easier way to do it using spatial querying etc but again I would need some pointers on how this could be done.

If it can’t be done, or there’s going to be too much work involved then we will most likely just leave our existing data as it is, but I’m quite anal about stuff like that so ideally I’d like to get it cleaned up and matching the new rules that we are trying to implement for any new data that is entered.

How to publish a service on ArcGIS Server using versioned data in ArcGIS 10.3?

$
0
0

Fairly new to GIS here, especially new to working with enterprise geodatabases. I am attempting to publish a service from arcmap to arcgis server using a version of the DEFAULT. I am using connection files from two separate databases in SQLserver 2008 (db1 and db2). Let me walk you through my processes:

  • add database connection using sde database authentication to db1
  • import data, manage privileges, register as versioned, add Global IDs
  • geodatabase administration > create new version from DEFAULT (named v1)
  • add new database connection using my windows authentication to db1
  • change geodatabase connection properties > select v1 from Transactional version
  • add data to arcmap from v1 version

Register database
When I register my geodatabase with ArcGIS Server, I import the connection file to db1 as the publisher database connection, and the connection file to db2 as the Server database connection, leaving the create geodata service option unchecked. The database registers and validates properly on arcgis server manager. The reason I have the separate server database connection is so I can replicate my data and synchronize my edits between my v1 version and arcgis online.

Next:
- right click my windows authenticated geodatabase > share as geodata service (so i can publish it in a specific folder)
- go through the publishing steps but when I click analyze, I keep getting the error 00133 Geodatabase is not registered with the server.

HOWEVER, when I follow these same steps using the DEFAULT version, it publishes fine. Arc does not seem to produce a separate connection file for the versions I create, so how do I get my service to recognize my registered geodatabase when publishing a version???

The same thing happens when I publish a map service (with feature access enabled) using v1 versus DEFAULT, except I get the error 00090 Feature service requires a registered database.


Losing elevation values converting to CAD in ArcGIS for Desktop?

$
0
0

This is complex and my first question. I’m using 10.3 and need to export a lot of contour files to CAD. When I do this individually, they convert fine and retain the elevation values. Having hundreds, I used model builder to accomplish this task and the elevation values come out wrong: .0001 feet.

Could the problem be with my iterator? I’m not familiar with these and wonder if not selecting the optional feature type is part of my problem. I’m going to run the model one more time with the “line” feature type selected.

Yes, I have the “Elevation” field properly named for the fickle CAD conversion. I do have an alias for it. Again, I can manually export to CAD without any issues.

Alphabetical Sort within a Record

$
0
0

I am performing a union on a polygon feature class with multiple overlapping polygons.
Each of the records in the resulting feature class can be thought of as “unique area” polygons made up of the various combinations of other polygons.

In my results I want each “unique area” record to contain the names of all the polygons that make it up, and I want those names listed alphabetically.

For example:
enter image description here
Ideal Resulting Table:

enter image description here

So far I have been able to do the union and then do a spatial join back to the original feature class and in the field map of the Spatial Join tool make the merge rule “Join” for attribute I want to concatenate (and indicate a delimiter). This gives me results like the following:

enter image description here

I can use .split(“,”) to divide this into separate fields.
My question is: how can I sort that Polys field so that those polygons are in alphabetical order?

Dissolving features to only have multiparts when they are within 100 feet of one another

$
0
0

I want to have a selection of parcels that is dissolved by land owner and within 3 miles of a polyline. If the same owner owns parcels on opposite sides of a road (within 100 feet or so), I want the parcel to be a multipart. However, I don’t want to have multiparts for parcels with the same owner that are >1 mile of each other.

This is part of a large model that I’m putting together. I’m sure python is the answer but I’m still very green with it. Is there a series of tools that will accomplish this?

I’m using ArcGIS Desktop 10.3 with the Advanced License.

Alpha channel in Arcgis Image Service

$
0
0

I have an issue to enable alpha channel in arcgis image service.

Image service published from a mosaic dataset in sde DB. The image files are geotiff images with 2 bands. First band supposed to be grey value and second – alpha channel. I use extract band function (with parameter “1 1 1 2″) in function chain of image service and it returns 4 bands as i want. But the alpha band still not activated – returned image is just first three band raster with no alpha.

In client i tried to set raster format to “png32″ but it not help.

As alternative I published Map Service of this mosaic dataset and manually activate alpha channel in symbology tab. But I want an image service with alpha channel not a map service.

Any suggestions?

*ArcGIS 10.3

Neatline disappears when resized [closed]

$
0
0

New-ish to GIS.

Using Arc 10.3 and experiencing an annoying problem. When attempting to resize a neatline (in order to use it as a locator box on my inset reference map) the lines disappears when reduced in size too quickly, or after getting below ~0.6×0.6″. The blue vertices remain visible afterwards, but cannot be selected/moved/brought forward.

Any thoughts or work arounds?

Shift in Feature Service within AutoCAD Since AGS 10.3 Upgrade

$
0
0

We use custom projections in ArcGIS for AutoCAD within which feature service displayed perfectly prior to our upgrade from AGS 10.1 to 10.3. For instance, our users have working drawing in which they connect to AGS, add the feature service and sync lines to the db. For some reason, just since the upgrade, the feature service comes in shifted entirely. Like I said it worked perfectly in 10.1. Civil 3D 2011.

Any ideas?

Text wrapping on tables in ArcMap?

$
0
0

I currently have a table (not a text box) that I’d like to have overlaid on the map in layout view of ArcMap 10.3. It, unfortunately, has a long title in the column. So, when I go to put the table on the map, it looks very elongated and generally not great. Is there a way that I can text-wrap the titles, and potentially also center-justify the data within the table? Neither the Options menu under Customize nor the Properties menu appear to have any helpful fixes.

I guess if there really isn’t any other option, I could just make a text box and then align everything by hand, but obviously this isn’t preferred.


inserting value from raster into overlaying point field

$
0
0

ArcGIS,10.3

I am using an etopo bathymetry map and would like to determine the depth of ~50k points in another layer. Im sure there is a simple tool for this but I am not very familiar with rasters.

I know thats not much of an explanation, but I think it explains the situation well enough.

Thank you!

Digitised problems – Combine isolines

$
0
0

I try to digitize a large number of topographic maps. Digitizes the contour every four meters. I use the program ArcGIS 10.3 and ArcSCAN. The problem is that it has many objects in the map outside of the contour and out of that the biggest problem is that the contours are continuous but is in many pieces. Is there a way to integrate automatically and in which way? It can be solved only by the topology? there is an automatic way to come together (Merge but only the same – meters iso lines)?

enter image description here

How do I enable Pop-ups by default for all layers in portal

$
0
0

I would like for Pop-ups to be enabled by default for all layers within portal.

For example, if a user goes to the “Map” tab whithin portal and adds a map service layer, I want “Enable Pop-up” to be set by default. How can I accomplish this?

enter image description here

Creating Feature Class in ArcPy gives RuntimeError?

$
0
0

I am new to Python.

I am trying to create a new Feature Class within a long script but before I do so, I am running it separately to make sure I have the syntax correct.
The code below mimics the one in the ESRI help documentation.

# create new featureclass in which to put points
import arcpy

arcpy.env.workspace = "C:/Test2"


out_path = "C:/Test2/GIS"
out_name = "RhinoLines.shp"
geometry_type = "POLYLINE"
spatial_reference = arcpy.Describe("C:/Test2/GIS/RhinoTracks.shp").spatialReference
print spatial_reference.Name

if arcpy.Exists(out_name):
    arcpy.Delete_management(out_name)

else:
    arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, spatial_reference)

But I keep getting this error:

  GCS_WGS_1984
Traceback (most recent call last):
  File "C:Python27ArcGIS10.3Libsite-packagespythonwinpywinframeworkscriptutils.py", line 326, in RunScript
    exec codeObject in __main__.__dict__
  File "C:Test2Scriptsstupid.py", line 20, in <module>
    arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, spatial_reference)
  File "C:Program Files (x86)ArcGISDesktop10.3ArcPyarcpymanagement.py", line 1807, in CreateFeatureclass
    raise e
RuntimeError: Object: Error in executing tool

Selection on Overlapping Polygons

$
0
0

I have converted a CAD file to GIS format using GIS (from .dgn to .shp)… In one layer I have polygons in which a smaller one is on top of the larger polygon. I can see both polygons however when I select the smaller polygon, the software automatically selects both the smaller polygon and the large one.
IS there anything I could do so that when I select the smaller one, the larger one doesnot get selected?

I don’t want to select both and then unselect one of them.

Viewing all 155 articles
Browse latest View live