<commit_before># generate-subjects-from-planet-api
Create Zooniverse subjects via Planet Labs API using area of interest (AOI) queries.

## Getting Started
Clone and `npm install`. You'll need a key to the Planet API and set it in the `PLANET_API_KEY` environmental variable.
There are three scripts set up to demonstrate what's currently implemented.

### Fetching Mosaics by Area of Interest (AOI)
Run `npm run-script planet-api-test` on the CLI to access the API and fetch mosaics intersecting with a polygonal AOI inscribing central Kathmandu. This should download two GeoTIF files in the `/data` directory along with corresponding JSON files containing the "Features" hash. This will be useful in the future for retrieving metadata and digging through individual scenes that make up the mosaic. It's also used as a placeholder to append the geo coordinates we'll calculate next.

### Computing Reference Coordinates
Run `npm run-script geo-coords-test` on the CLI. This will extract the coordinates of the corner and center pixels of one of the GeoTIF files (`data/L15-1509E-1188N.tif`) that were downloaded in the previous section. The resulting coordinates are appended in the `reference_coordinates` hash of its corresponding JSON file.

```
"reference_coordinates": {
	"upper_left": {
		"lat": 27.839074999999998,
		"lon": 85.25390555555556
	},
	"upper_right": {
		"lat": 27.839074999999998,
		"lon": 85.42968611111111
	},
	"bottom_right": {
		"lat": 27.68352777777778,
		"lon": 85.42968611111111
	},
	"bottom_left": {
		"lat": 27.68352777777778,
		"lon": 85.25390555555556
	},
	"center": {
		"lat": 27.761330555555556,
		"lon": 85.34179722222221
	}
}
```

### Generating Tiles
Run `npm run-script tilize-images` on the CLI. This will split one of the downloaded mosaic GeoTIFs (`data/L15-1509E-1188N.tif`) into tiles 480px square, with 160px overlap between tiles and write a subject set file (`data/manifest.csv`) ready to upload to Panoptes. For customisation options, run `node tilize-images`.

TO DO: Interpolate geo coords of individual tiles and generate metadata. Creating subjects and loading into Panoptes follows.
<commit_msg>Mark tilize as broken (I removed the script, will replace it)<commit_after># generate-subjects-from-planet-api
Create Zooniverse subjects via Planet Labs API using area of interest (AOI) queries.

## Getting Started
Clone and `npm install`. You'll need a key to the Planet API and set it in the `PLANET_API_KEY` environmental variable.
There are three scripts set up to demonstrate what's currently implemented.

### Fetching Mosaics by Area of Interest (AOI)
Run `npm run-script planet-api-test` on the CLI to access the API and fetch mosaics intersecting with a polygonal AOI inscribing central Kathmandu. This should download two GeoTIF files in the `/data` directory along with corresponding JSON files containing the "Features" hash. This will be useful in the future for retrieving metadata and digging through individual scenes that make up the mosaic. It's also used as a placeholder to append the geo coordinates we'll calculate next.

### Computing Reference Coordinates
Run `npm run-script geo-coords-test` on the CLI. This will extract the coordinates of the corner and center pixels of one of the GeoTIF files (`data/L15-1509E-1188N.tif`) that were downloaded in the previous section. The resulting coordinates are appended in the `reference_coordinates` hash of its corresponding JSON file.

```
"reference_coordinates": {
	"upper_left": {
		"lat": 27.839074999999998,
		"lon": 85.25390555555556
	},
	"upper_right": {
		"lat": 27.839074999999998,
		"lon": 85.42968611111111
	},
	"bottom_right": {
		"lat": 27.68352777777778,
		"lon": 85.42968611111111
	},
	"bottom_left": {
		"lat": 27.68352777777778,
		"lon": 85.25390555555556
	},
	"center": {
		"lat": 27.761330555555556,
		"lon": 85.34179722222221
	}
}
```

### Generating Tiles (currently broken)
Run `npm run-script tilize-images` on the CLI. This will split one of the downloaded mosaic GeoTIFs (`data/L15-1509E-1188N.tif`) into tiles 480px square, with 160px overlap between tiles and write a subject set file (`data/manifest.csv`) ready to upload to Panoptes. For customisation options, run `node tilize-images`.

TO DO: Interpolate geo coords of individual tiles and generate metadata. Creating subjects and loading into Panoptes follows.

{'fraction_non_alphanumeric': 0.08419362239045652, 'fraction_numerical': 0.08671713695801789, 'mean_word_length': 4.744400527009223, 'pattern_counts': {'":': 32, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 20, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2572641', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1267, 'n_words': 550}