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

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

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 ...


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 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 ...


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

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.


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

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.


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

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 ...


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

Try saving as CSV and see all the answers and comments on How to best prepare csv files for use in arcgis. Once it is imported into ArcGIS you can export/convert to dbf or gdb or other table format.


3

Your data are in a rectangular array. Their locations are not explicitly given, but are implicit in their positions within the array (their row and column indexes). You need to rearrange them with one value per record and you need to compute coordinates for each record. The spreadsheet is the place to do this, not the GIS. Here is an Excel example (using ...


3

If your data is an Excel table to start with, you can do a global search and replace in Excel before importing to ArcGIS.


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 + "\\" + ...


3

At ArcGIS 10.2 for Desktop a new tool called Table To Excel (Conversion) was introduced to export a table to an Excel file. Summary Converts a table to a Microsoft Excel file. Usage • Table To Excel is able to convert only to Microsoft Excel 5.0/95 Workbook (.xls) format.


3

Make sure there are no spaces in filenames, sheetnames or fieldnames.


3

Are the types the same (i.e. both integers/both doubles) both in Excel and ArcMap? Also you may need to make the excel file into a database or CSV in order to join them (just use 'save as' in Excel to change the file type). I've had trouble with Excel files in the past, sometimes it is also because it's the .xlsx (new filetype for the new MS Office) rather ...



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