|
POST
|
@JoshuaBixby then will the result be the division of the two numbers (not what OP wants) instead of a string with the two numbers separated by a forward slash (what the OP wants)?
... View more
07-29-2022
03:57 PM
|
1
|
1
|
2945
|
|
POST
|
The error message is telling you that you can't add a string to a number. The "+" operator is for adding numbers or concatenating strings, not adding or concatenating strings to numbers. Use string formatting instead: C = f"{!A!} / {!B!}"
# or
C = "{} / {}".format(!A!, !B!)
# or
C = "%s / %s" % (!A!, !B!)
... View more
07-29-2022
02:23 AM
|
2
|
0
|
3000
|
|
POST
|
The only one you can add to ArcGIS Pro is the .ecw. It's a raster dataset. Make sure you have a map open in Pro, then just drag it onto your map from your catalog pane, or use the add data button and navigate to the .ecw file, or you can drag and drop from Windows Explorer. The .eww and prj files are what's called sidecar or metadata files, they just contain georeferencing information for the .ecw raster. You can't (and don't need to) add them to Pro.
... View more
07-25-2022
03:09 AM
|
1
|
0
|
9937
|
|
POST
|
It's even easier these days with arcpy.EnvManager with arcpy.EnvManager(workspace=r"D:\Data"):
some_function()
... View more
07-24-2022
03:08 PM
|
1
|
0
|
7983
|
|
POST
|
A kmz is just a zipped kml (plus some other optional bits and pieces), you can unzip it and extract the kml. You could automate the unzipping with python and create your own geoprocessing layer to kml tool that actually outputs kml. So yes there is a way to export a KML rather than a kmz from ArcPro, but you need a small script to run layer to kml then unzip the "doc.kml" file contained in the kmz.
... View more
07-22-2022
10:08 PM
|
0
|
0
|
5572
|
|
POST
|
To add to Dan's answer arcpy.da.Describe(your_raster)["noDataValue"]
# or
arcpy.Raster(your_raster).noDataValue https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/raster-object.htm#P_GUID-E0D56F9F-CABB-4BB7-BE6F-E96E02858F00
... View more
07-11-2022
05:26 PM
|
1
|
0
|
3622
|
|
POST
|
According to the help page How Kernel Density works the kernel function is based on the quartic kernel function described in Silverman (1986, p. 76, equation 4.5). The formulas are included in that help page. Silverman, B. W. Density Estimation for Statistics and Data Analysis. New York: Chapman and Hall, 1986.
... View more
07-08-2022
04:11 AM
|
0
|
1
|
1837
|
|
POST
|
You don't need "variable" variable names. Just rename the columns before you write out to CSV. e.g. columns = ["sedan", "wagon", "convertible"]
new_columns = [f"{c}_dom" for c in columns] Here's a pandas version: import pandas as pd
from io import StringIO # not required if reading csv from file
# Dummy csv to demo, can also read from csv file
csv = """dealer,car,sedan,wagon,convertible, junk
A,Ford,Red,0,Green, None
A,GMC,Blue,Red,0, None
B,BMW,Green,0,Red, None
B,Ford,0,Blue,Red, None
C,BMW,0,Green,0, None
C,GMC,Red,Blue,Red, None
D,GMC,Red,Blue,Blue, None
D,GMC,Red,Blue,0, None
"""
columns = ["sedan", "wagon", "convertible"] # ignore the junk etc, columns that aren't of interest
dom_columns = {c: f"{c}_dom" for c in columns}
df = pd.read_csv(StringIO(csv)) # or df = pd.read_csv(r"path/to/csv")
dom_df = df[columns].mode().rename(columns=dom_columns)
dom_df.to_csv("dom.csv", index=False)
... View more
07-07-2022
04:11 PM
|
0
|
0
|
7293
|
|
IDEA
|
Good idea. Esri should implement this idea as well as Make arcpy.AddWarning wrapped in script warnings! - Esri Community
... View more
07-06-2022
01:59 AM
|
0
|
0
|
4963
|
|
IDEA
|
Good idea. But Esri would also have to implement this idea: Interpret warnings as warnings instead of errors in Python tools
... View more
07-06-2022
01:55 AM
|
0
|
0
|
1197
|
|
POST
|
Your use case is a bit unclear to me Craig, could you add a bit of pseudo-code to try and illustrate what you're trying to do? But if what I think you're trying to do is correct, the following might help...? # Just some simple dummy data,
# you could have a car class or pandas dataframe with car colour, make, model, etc... details
cars = ["red", "red", "blue", "white", "white", "red", "blue", "white"]
car_colours = {}
for colour in cars:
car_colours[colour] = car_colours.get(colour, 0) + 1
# could also use
try:
car_colours[colour] += 1
except KeyError:
car_colours[colour] = 1
# Now show all colours and how many cars were that colour
for colour, count in car_colours.items():
print(f"There were {count} {colour} cars.")
# Now just print how many red and orange cars:
print(f"There were {car_colours['red']} red cars.")
print(f"There were {car_colours.get('orange', 0)} orange cars.")
# I use .get instead of ["key"] as I know there's no orange cars and would otherwise get a KeyError Output: There were 6 red cars.
There were 4 blue cars.
There were 6 white cars.
There were 6 red cars.
There were 0 orange cars.
... View more
07-05-2022
11:32 PM
|
0
|
1
|
7310
|
|
POST
|
@MichaelFowler1 wrote: I have tried both the above methods and its still not working for me. Weird, works fine for me. @MichaelFowler1 wrote: crs = 'WGS 1984'
arcpy.env.outputCoordinateSystem = crs
RuntimeError: Object: Error in accessing environment <outputCoordinateSystem>
utm = 'WGS 1984 UTM Zone 56S'
arcpy.env.outputCoordinateSystem = utm
RuntimeError: Object: Error in accessing environment <outputCoordinateSystem> If you want to hardcode a spatial reference: crs = arcpy.SpatialReference(4326) # 'WGS 1984' https://epsg.io/4326
arcpy.env.outputCoordinateSystem = crs
utm = arcpy.SpatialReference(32756) # 'WGS 1984 UTM Zone 56S' https://epsg.io/32756
arcpy.env.outputCoordinateSystem = utm
... View more
07-01-2022
03:04 AM
|
0
|
0
|
3323
|
|
POST
|
You are mixing up old style arcpy.Describe with arcpy.da.Describe arcpy.da.Describe returns a dictionary, use desc["datasetType"] instead.
... View more
06-29-2022
04:44 PM
|
3
|
0
|
2480
|
|
POST
|
Use the SpatialReference or CoordinateSystem objects directly (i.e. use arcpy.GetParameter instead of GetParameterAsText) import arcpy
#This works
sr = arcpy.GetParameter(0)
arcpy.env.outputCoordinateSystem = sr
#So does this
crs = arcpy.GetParameter(1)
arcpy.env.outputCoordinateSystem = crs
... View more
06-29-2022
01:59 PM
|
0
|
2
|
3338
|
|
POST
|
Did you clone your previous arcgispro-py3 environment?
... View more
06-28-2022
01:58 AM
|
1
|
0
|
5249
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-24-2022 03:08 PM | |
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM |