|
8 | 8 | "source": [ |
9 | 9 | "# Generate PDF Report\n", |
10 | 10 | "\n", |
11 | | - "This example shows how to generate an HTML and PDF report for a specific feature layer. It demonstrates how to create a report that includes summary statistics, photos, maps, and attribute information. In this example we are going to work with a tree inventory layer that was deployed using this [ArcGIS Solution template](https://www.arcgis.com/apps/solutions/index.html?gallery=true&searchTerm=Tree%20Management&solution=vrrh5yvnj1b8ba2tkfab6kf36c2t18np).\n", |
| 11 | + "This example shows how to generate an HTML and PDF report for a specific feature layer. It demonstrates how to create a report that includes summary statistics, photos, maps, and attribute information. In this example we are going to work with a tree inventory layer that was deployed using this [ArcGIS Solution template](https://www.arcgis.com/apps/solutions/index.html?gallery=true&searchTerm=Tree%20Management&solution=vrrh5yvnj1b8ba2tkfab6kf36c2t18np) and the Trees Hosted Layer or Trees_public Hosted Layer View. \n", |
12 | 12 | "\n", |
13 | 13 | "This notebook was originally created as part of DevSummit 2021." |
14 | 14 | ] |
|
44 | 44 | } |
45 | 45 | ], |
46 | 46 | "source": [ |
47 | | - "gis = arcgis.gis.GIS(\"<org>\", \"<username>\")\n", |
| 47 | + "gis = arcgis.gis.GIS(\"https://www.arcgis.com\", \"<username>\")\n", |
48 | 48 | "item = gis.content.get(\"<item-id>\")\n", |
49 | 49 | "trees_layer = item.layers[0]" |
50 | 50 | ] |
|
124 | 124 | "def get_location_data(exif_data):\n", |
125 | 125 | " gps_info = exif_data.get_ifd(ExifTags.IFD.GPSInfo)\n", |
126 | 126 | " time = dt.now()\n", |
127 | | - " if gps_info is None:\n", |
128 | | - " return (0, 0)\n", |
| 127 | + " try:\n", |
129 | 128 | "\n", |
130 | | - " lat_degrees = gps_info[ExifTags.GPS.GPSLatitude][0]\n", |
131 | | - " lat_minutes = gps_info[ExifTags.GPS.GPSLatitude][1]\n", |
132 | | - " lat_seconds = gps_info[ExifTags.GPS.GPSLatitude][2]\n", |
133 | | - " lon_degrees = gps_info[ExifTags.GPS.GPSLongitude][0]\n", |
134 | | - " lon_minutes = gps_info[ExifTags.GPS.GPSLongitude][1]\n", |
135 | | - " lon_seconds = gps_info[ExifTags.GPS.GPSLongitude][2]\n", |
| 129 | + " lat_degrees = gps_info[ExifTags.GPS.GPSLatitude][0]\n", |
| 130 | + " lat_minutes = gps_info[ExifTags.GPS.GPSLatitude][1]\n", |
| 131 | + " lat_seconds = gps_info[ExifTags.GPS.GPSLatitude][2]\n", |
| 132 | + " lon_degrees = gps_info[ExifTags.GPS.GPSLongitude][0]\n", |
| 133 | + " lon_minutes = gps_info[ExifTags.GPS.GPSLongitude][1]\n", |
| 134 | + " lon_seconds = gps_info[ExifTags.GPS.GPSLongitude][2]\n", |
136 | 135 | "\n", |
137 | | - " lat = float(lat_degrees + lat_minutes / 60 + lat_seconds / 3600)\n", |
138 | | - " lon = float(lon_degrees + lon_minutes / 60 + lon_seconds / 3600)\n", |
| 136 | + " lat = float(lat_degrees + lat_minutes / 60 + lat_seconds / 3600)\n", |
| 137 | + " lon = float(lon_degrees + lon_minutes / 60 + lon_seconds / 3600)\n", |
139 | 138 | "\n", |
140 | | - " if gps_info[ExifTags.GPS.GPSLatitudeRef] == \"S\":\n", |
141 | | - " lat = -lat\n", |
142 | | - " if gps_info[ExifTags.GPS.GPSLongitudeRef] == \"W\":\n", |
143 | | - " lon = -lon\n", |
144 | | - " if ExifTags.GPS.GPSTimeStamp in gps_info:\n", |
145 | | - " time = gps_info[ExifTags.GPS.GPSTimeStamp]\n", |
| 139 | + " if gps_info[ExifTags.GPS.GPSLatitudeRef] == \"S\":\n", |
| 140 | + " lat = -lat\n", |
| 141 | + " if gps_info[ExifTags.GPS.GPSLongitudeRef] == \"W\":\n", |
| 142 | + " lon = -lon\n", |
| 143 | + " if ExifTags.GPS.GPSTimeStamp in gps_info:\n", |
| 144 | + " time = gps_info[ExifTags.GPS.GPSTimeStamp]\n", |
| 145 | + "\n", |
| 146 | + " except Exception as e:\n", |
| 147 | + " lat = 0\n", |
| 148 | + " lon = 0\n", |
| 149 | + " time = dt.now()\n", |
146 | 150 | "\n", |
147 | 151 | " return (lat, lon, time)" |
148 | 152 | ] |
|
312 | 316 | ], |
313 | 317 | "metadata": { |
314 | 318 | "kernelspec": { |
315 | | - "display_name": "cartopy-dev", |
| 319 | + "display_name": "field-maps-scripts-99999", |
316 | 320 | "language": "python", |
317 | 321 | "name": "python3" |
318 | 322 | }, |
|
326 | 330 | "name": "python", |
327 | 331 | "nbconvert_exporter": "python", |
328 | 332 | "pygments_lexer": "ipython3", |
329 | | - "version": "3.10.11" |
| 333 | + "version": "3.11.11" |
330 | 334 | } |
331 | 335 | }, |
332 | 336 | "nbformat": 4, |
|
0 commit comments