Tag Info

Hot answers tagged

13

This works for me, using the arcpy.da.Walk function at ArcGIS 10.1 SP1: import arcpy, csv, os workspace = r"c:\GISData" output = r"C:\temp\test.csv" with open(output, 'wb') as csvfile: csvwriter = csv.writer(csvfile) for dirpath, dirnames, filenames in arcpy.da.Walk(workspace): for filename in filenames: desc = ...


10

All of the trigonometric functions you need are in the math module. I presume you'll want atan2() which is the equivalent of atan(y/x). For the mod function, you'll need to use the percent symbol. Each function also has a simplified version (a) since you are calculating some constants. They're identical functions but will be faster. Parser: Python ...


9

Like whuber says, you have to write out the headers explicitly. I loaded up dbfpy and xlwt in a virtualenv and ran this: from xlwt import Workbook, easyxf import dbfpy.dbf from time import time def test1(): dbf = dbfpy.dbf.Dbf("pipelines.dbf", readOnly = True) header_style = easyxf('font: name Arial, bold True, height 200;') book = Workbook() ...


8

Threading doesn't work with most UI manipulation in Windows as UI elements have thread affinity, which is probably why the map view is failing to refresh. I've got a Python project that does this in ArcGIS without threading on Github. It uses the Win32 event loop in the main thread to do timed calls in an add-in extension. You can also use it independently ...


7

Try ET Geowizards Generate (Import from Text) and use a Box type. If new to this free (some tools only) ArcGIS addon, go to http://www.ian-ko.com. For this you need to do a some simple formatting of your excel to be id,xmin,ymin,xmax,ymax - formatting is explained in the tool help.


7

When you use Python, you must use the correct modules to do what you want. To find all files in a directory with extension shp, for example, there are much simpler solutions that was presented without the break, which is awful...(as the solution presented by Nathan W, but there are many, many others, just search on Internet) Some examples with relevant ...


6

If you open the attribute table, open an empty excel spreadsheet, Select all or some of the records in the attribute table. to select all the button in upper left gives this pulldown to accomplish that. right click on the left edge (on a box). copy selected. Switch to the spreadsheet. right click in the upper left cell (just one cell) ctrl+V ...


6

You'll need to use the xlrd module to read Microsoft Excel files (I think it's limited to .xls files only). To open your spreadsheet and read cell A2, you would use the following: import xlrd book = xlrd.open_workbook(r"C:\MMO_Model_Test\testdata.xlsx") # may not work with .xlsx file sh = book.sheet_by_index(0) # opens the first worksheet val = ...


6

What you want to do is not a clip, a clip operation would mean you are removing geometry from a layer using another layer as the clipping boundary. You want to do a Join. To do it in ArcGIS, which I assume you're using because you mention modelbuilder: Add the shapefile to your project. Right-click the layer's name, click Joins and Relates > Join... Choose ...


6

Given a list of geographic coordinate pairs, you can implement the Haversine formula directly in Excel. The simplest way to use this (or a more accurate, but I think it's not your case) formula consists into press Alt+F11 to open the VBA Editor, click Insert --> Module and then (copy and) paste e.g. the code kindly suggested by blah238. There will be a ...


6

Install the XY Tools plugin by Richard Duivenvoorde. Select a vector file from the ToC (that is, make it active). Go to Vector->XY tools->Save attribute table as Excel file. You would need the Python library xlw installed for doing so.


6

Save your Excel as a comma-delimited file, then: COPY your_table FROM '/path/to/csv/file/data.csv' WITH DELIMITER ',' CSV HEADER; Another option would be ogr2ogr. Edit: after some more searching, the answers to this question should help.


5

You can still do this, although Excel has made it more difficult by breaking the loading sequence for associated .dbf's. Export normally. Open Excel on its own. Go to File -> Open, select 'All Files', and find the .dbf.


5

This is expected behavior. The ESRI Maps for Office help references this: Heat map layers and layers that are clustered cannot be shared to ArcGIS Online as a layer, but can be shared as part of a map. In the ArcGIS.com Map Viewer, the heat map layer displays as a point layer instead of rendering as a heat map. Source


5

One of the great things about structured text like this (generally fixed width data) is that it is pretty easy to parse out using a programming language. I used almost the same approach that @congrene used, but I wrote it with Python, which is widely used in the GIS community. You'll note that in many cases the City and State are not fully populated. ...


5

If I understand this correctly the yellow fields contain X and Y values, and all the other cells contain some other value like elevation? If I was you I'd convert the data to a text file following this general pattern: X-coordinate;Y-coordinate;elevation You can do this within with a formula like this: The upper table is my test data, with 11, 22, 33 ...


5

I believe you want this toolset downloadable from the arcgis.com gallery, compatible (supposedly) with 10.0 and above (written by teampython): Excel and CSV Conversion Tools Also see the below esri blog (the internal link provided is broken; why I provided the link I think they're referring to above...in later versions, as you know, esri's packaged a ...


4

If it's a .csv file you can edit the schema.ini file so that it includes a custom date format string: DateTimeFormat=YYYY-MM-DD HH:mm:s


4

Here is a technical document describing some of the basic VBA calculator functions, with links to some short walk-throughs. And here is some narrative (with examples) on using the Field Calculator and VBA. Remember that using VBA in the field calculator is only valid for 9.3.1 and not 10 (which uses python and VBScript).


4

If you have ArcGIS Desktop 10.0 (or any of its service packs), I think your best bet is writing a python script that uses os.walk to look through a defined GIS directory and searches for common GIS file extensions such as .shp, .gdb, .mdb, etc... and writes the result to a comma delimited text file. You can then bring the text file into excel, see code ...


4

ArcGIS uses Microsoft technology to read Office formats, Excel and Access. The default is to read the first 8 rows to determine column datatypes. Changing this registry key forces the entire table to be read first. The infered datatypes and widths are much more accurate, especially for .csv. \hklm\software\wow6432node\microsoft\jet\engines\excel ...


4

In general, workflows that you would like to automate I would recommend first doing it manually. Once you have that logic understood (what tools to use when), then yoiu could create a model/python script. For this case here would be the general model workflow (assuming you are using ArcGIS): Use Make XY Event Layer tool to create the GIS layer Use Add ...


4

Are the longitude and latitude values in separate fields? Because the Convert_Decimal function requires a single value. After trying this myself, I think you were trying to convert the DMS values to DD in-place. That is, in the same column. Instead, use the script in a new column, referring to the one you want to convert. See image below where I have a DMS ...


4

The quickest way to do this with a single line would be using the QuickWKT plugin; you can then right-click and Save As to any format you need. Let's say your two points are in UTM Zone 36S, and here are listed as x (easting), y (northing): 151930,9593414 184802,9587212 The WKT format for a line is: SRID=SRID;LINESTRING (x1 y1, x2 y2, x3 y3, ...) ...


4

What I'd probably do in ArcMap: Create a new feature class and start adding new features. As you place each point on the map, and note in your Excel file what the OBJECTID for the point is. Then, once you are done creating points, Join the Excel file to the feature class and the property owners can be copied over to the feature class. Another way in ArcMap: ...


4

Cities can be reasonably approximated as points, and it is therefore possible to put columns for latitude and longitude in the Excel file and then import them into ArcMap. To find those coordinates, there are a wide array of websites; some have well-known cities in a table [example], others let you look up the city [example], and a quick Google search will ...


4

Extracting coordinates of start/end vertices (not all line vertices) from lines is a nice use case for new functionality in QGIS v.2.8, namely, the function editor. This is the workflow: Load your line layer to QGIS and activate it. Open the field calculator and go to tab Function Editor. Click on New file, write vertices as the new file name, and click ...


4

Here's what I do for Microsoft Excel files: Preprocess the source Excel Worksheet to ensure that the headers are on the first row, and all data from row 2 and downwards look normal. This may need to be revised if the next step has difficulties Start Microsoft Access and create a Blank database. Navigate to "External Data", and choose to Import Excel, and ...


3

I'm not sure that this helps with your specific question, and you may well have already seen it, but this is another useful link from the Esri Training Matters blog: Formatting Excel Data for Use in ArcGIS Desktop


3

Thanks artwork21 and Nathan W for your response. And yes Nathen's code made the magic. import os, arcpy #create blank text file with open("C:\\Temp\\GISlayers.txt", "w") as txt: for root, dirs, files in os.walk("C:\\Temp\\temp"): for f in files: #look for shapefiles if f.endswith('.shp'): desc = arcpy.Describe(root + "\\" + ...



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