Tag Info

Hot answers tagged

12

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


8

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

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


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

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

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


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


3

Adding to @Rob Lodge 's answer above. you can directly convert excel file to .csv format and there is a plugin called mmqgis here you can add attributes join from .csv file . i think this may help you if your shapefile dosent have latitude and longitude as seprate fields in excel.


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

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

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

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

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


3

Here is the ESRI help page on joining a shapefile to an Excel file: http://support.esri.com/en/knowledgebase/techarticles/detail/31793 I've followed those guidelines in the past when I had problems and I was able to get the data joined. For some more information, here is a whitepaper from ESRI on working with Excel in ArcGIS: ...


3

You can't change the data type of a field in ArcGIS, you'll have to create new fields with the data types you want and populate them with the values from your current fields. See: How to change field formats in ArcGIS 10.1 geodatabase?


3

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


3

Two things I noticed are: The line with arcpy.da.UpdateCursor... has no opening square bracket "[" but it has a closing "]" The line arcpy.ExcelToTable_conversion("C:\Sitescores.xlsx", "Carescores") has just one \ when it should be two.


3

The Table To Excel (Conversion) tool which was new at ArcGIS 10.2 has the usage below. TableToExcel_conversion (Input_Table, Output_Excel_File, {Use_field_alias_as_column_header}, {Use_domain_and_subtype_description}) As you can see it writes to an Excel file and does not provide an option to specify a worksheet within an Excel file as output. ...


3

It works with 10.1, so it's looks like a bug of 10.2. If you are in this situation: ArcMap crashes when an XY event layer is in the data frame and the Get Point Features dialog box is opened from the Find Route tool you appear to be encountering bug NIM094607 which is due to be fixed at ArcGIS 10.2.1. Maybe you could try to export your data in ...



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